tags: Java front end json javascript
<%@page import="net.sf.json.JSONArray"%>
List<Map<String, Object>> dataList = xxxxx;
// js code
var allCollectedRecords =<%=JSONArray.fromObject(dataList)%>; // [{"OID":"12345","NAME":"test"},{"OID":"659","NAME":"yuwang"}]
var refMap = <%=JSONArray.fromObject(dataList).getJSONObject(0)%>;
var OID = refMap["OID"];
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
String data = (String)params.get("data"); // "[{\"OID\":\"12345\",\"NAME\":\"test\"},{\"OID\":\"659\",\"NAME\":\"yuwang\"}]"
JSONArray jsonArray=JSON.parseArray(data);
JSONObject partObj = jsonArray.getJSONObject(0);
String partOid = (String) partObj.get("OID");
var obj = {"name":"test", "site":"aaaaa"}
var str = JSON.stringify(obj);
alert(str);
It is usedcom.alibaba.fastjson.JSONObject JSONObject the maven-dependent: People.java JSONObjectTest.java test class Print Console as follows: to sum up Entity Object convert Json string class using J...
Json-lib is used to complete the transformation of beans, collections, maps, java arrays, XML and JSON between jars, json-lib depends on several other jar packages (I tried all jars with the latest v...
concept String: This well explained, referring to the use of "" or double quotes '' comprises a single quote character. E.g: String comStr = "this is string; " Json: refers to the ...
1 JSONObject Add a jsonobject Print results E / ===== jsonObject: { "age": "23", "hobby": "Game", "name": "Komaki"} 1.1 acquisition va...
Write a directory title here JsonObject source code jsonArray JsonObject source code jsonArray...
First, application scenario 1. The java class in the background, such as solid classes, list, set, map to the JSON string to be sent to the front or other items 2. JSON string sent by the front or oth...
content Introduction demo Introduction demo plant test Output result Refer...