Home > Web Front-end > JS Tutorial > Example of js parsing json and reading entity objects in List_javascript skills

Example of js parsing json and reading entity objects in List_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:55:46
Original
2140 people have browsed it

1. To pass the background action to the front desk, you need to convert the map into json format

Copy the code The code is as follows:

Map resultMap;
JSONObject json = JSONObject.fromObject(resultMap);
message = json.toString();

Store multiple items in List student object

2. In the front-end js, first convert the resulting json string into an object
Copy code The code is as follows:

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

3. Traverse the objects in the list
Copy code The code is as follows:

for(var key in obj){ //The first level of loop gets each list
var List = obj[key];
for(var student in List){ //The second level loop takes the objects in the list
alert(List[student ].id);
alert(List[student ].name);
}
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Backslash present in Json
From 1970-01-01 08:00:00
0
0
0
Get: Transfer JSON data
From 1970-01-01 08:00:00
0
0
0
mysql storage json error
From 1970-01-01 08:00:00
0
0
0
javascript - Problems with displaying json data
From 1970-01-01 08:00:00
0
0
0
Find matching integers in JSON.
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template