SoFunction
Updated on 2025-03-03

js parsing json to read entity objects in List

1. The map needs to be converted to json format from the background action to the front desk.

Copy the codeThe code is as follows:

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

Store multiple student objects in List

2. First convert the result json string into an object in the front desk js
Copy the codeThe code is as follows:

var obj = eval("("+data+")");

3. Traversal and take objects in list
Copy the codeThe code is as follows:

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

PS: Regarding json operation, here are some more practical json online tools for your reference:

Online JSON code verification, inspection, beautification and formatting tools:
http://tools./code/json

JSON online formatting tool:
http://tools./code/jsonformat

Online XML/JSON mutual conversion tool:
http://tools./code/xmljson

json code online formatting/beautification/compression/editing/converting tools:
http://tools./code/jsoncodeformat

Online json compression/escaping tools:

http://tools./code/json_yasuo_trans

C language style/HTML/CSS/json code formatting and beautification tools:
http://tools./code/ccode_html_css_json