Js parses json to read the sample entity object in the List

  • 2020-03-30 02:20:45
  • OfStack

1. From the background action to the foreground, the map needs to be converted into json format

 
Map<String, List> resultMap ;
JSONObject json = JSONObject.fromObject(resultMap);
message = json.toString();

The List contains multiple student objects

2. In foreground js, turn the result json string into an object first
 
var obj = eval("("+data+")");

3. Iterate through the objects in the list
 
for(var key in obj){ //The first layer loops to each list
var List = obj[key];
for(var student in List){ //The second loop takes the object in the list
alert(List[student ].id);
alert(List[student ].name);
}
}

PS: about json operation, here again for you to recommend a few more practical json online tools for your reference:

Online JSON code verification, verification, beautification, formatting tools:
(link: http://tools.jb51.net/code/json)

JSON online formatting tool:
(link: http://tools.jb51.net/code/jsonformat)

Online XML/JSON interconversion tool:
(link: http://tools.jb51.net/code/xmljson)

Json code online formatting/beautification/compression/editing/conversion tools:
(link: http://tools.jb51.net/code/jsoncodeformat)

Online json compression/escape tool:

(link: http://tools.jb51.net/code/json_yasuo_trans)

C language style /HTML/CSS/json code format beautification tool:
(link: http://tools.jb51.net/code/ccode_html_css_json)


Related articles: