更新时间:2023-01-17 16:30:40
您可以尝试像这样:
Gson gson = new Gson();
Type type = new TypeToken< HashMap< String,String>>(){}。getType();
HashMap< String,String> map = new HashMap< String,String>();
map = gson.fromJson(json,type);
其中json是您定义的json字符串。
I'm not very familiar with Java, but got the job to reverse the following JSON-Output to a JAVA object-structure:
Sample:
{"MS":["FRA",56.12,11.67,"BUY"],"DELL":["MUC",54.76,9.07,"SELL"]}
Does someone know, how to build the Arrays / Objetcs and the code to read the strings with Java? JSON or GSON codesamples are welcome.
Thanks!
You could try something like:
Gson gson = new Gson();
Type type = new TypeToken<HashMap<String, String>>(){}.getType();
HashMap<String, String> map = new HashMap<String, String>();
map = gson.fromJson( json, type );
Where "json" is the json string you defined.