JSON format description

Source: Internet
Author: User

The code is as follows:

for (int i1 = 0, L = list.size (), I1 < L; i1++) {object[] t = (object[]) list.get (i1); node = new node (t[1].tostring (), T[0].tostring ()); Nodelist.add (node); List L1 = new ArrayList (); List L2 = new ArrayList (); Map m = new HashMap (); M.put ("name", Personplace); Map m2 = new HashMap (); M2.put ("Name", T[1].tostring ()); L1.add (m); L1.add (m2); Map m3 = new HashMap (), M3.put ("name", T[1].tostring ()), M3.put ("Value", t[0].tostring ()), L2.add (m); L2.add (m3); Placeslink.add (L1); Placecounts.add (L2); String a = Jsonmapperutils.objecttojson (L2); String B = Jsonmapperutils.objecttojson (placecounts); String C = Jsonmapperutils.objecttojson (m3); String d = Jsonmapperutils.objecttojson (L1);}

Output Result:

One-dimensional arrays:
String[] A = new string[phonelist.size ()];

Two-dimensional arrays:
String[][] b =new string[phonelist.size ()][2];
Map
M: {name= beijing}m3:{name= Nanchang, value=2}

List:l1:[{name= Beijing}, {name= Nanchang}]l2:[{name= Beijing}, {name= Nanchang, value=2}]

Listplacecounts:[[{name= Beijing} In list, {name= Nanchang, value=2}]] corresponding JSON format:
A:
["A", "B", "C"]
B:
[["A", "B"],["A1", "B1"],["C1", "D1"],["C12", "D22"]]m3:{"name": "Nanchang", "Value": "2"}l2:[{"name": "Beijing"},{"name": "Nanchang", " Value ":" 2 "}]placecounts:[[{" name ":" Beijing "},{" name ":" Nanchang "," Value ":" 2 "}]][[{" name ":" Beijing "},{" name ":" Nanchang "," Value ":" 2 "}], [{"Name": "Beijing"},{"name": "Chongqing", "Value": "4"}]]

 

map<string, object> info = new hashmap<string, object> ();
Info.put ("NodeList", nodeList); Info.put ("Placeslink", Placeslink); Array Info.put ("Placecounts", placecounts); Array string json = Jsonmapperutils.objecttojson (info);

Output results

{"Phonenums": ["Beijing"], "nodeList": [{"Name": "Nanchang", "Value": "2"},{"name": "Chongqing", "Value": "4"},{"name": "Lhasa", "Value": "2"}, {"Name": "Shanghai", "Value": "1"}],
"Placecounts": [["Name: Beijing", "Name: Nanchang, value:2"],["Name: Beijing", "Name: Chongqing, Value:4"],["Name: Beijing", "Name: Lhasa, Value:2"],[" Name: Beijing "," Name: Shanghai, value:1 "],
"Success": true, "Placeslink": [["{Name: Beijing}", "{Name: Nanchang}"],["{Name: Beijing}", "{Name: Chongqing}", "{Name: Beijing}", "{Name: Lhasa}"],["{ Name: Beijing} "," {Name: Shanghai} "]}

map<string, object> info = new hashmap<string, object> (); Info.put ("NodeList", nodeList); Info.put (" Placeslink ", Placeslink); List<list<map<key,value>>>string JSON = Jsonmapperutils.objecttojson (info);

Output results

{"Phonenums": ["Beijing"],
"NodeList": [{"Name": "Nanchang", "Value": "2"},{"name": "Chongqing", "Value": "4"},{"name": "Lhasa", "Value": "2"},{"name": "Shanghai", "value" : "1"}],
"Placecounts": [[{"Name": "Beijing"},{"name": "Nanchang", "Value": "2"}],[{"name": "Beijing"},{"name": "Chongqing", "Value": "4"}],[{"name": " Beijing "},{" name ":" Lhasa "," Value ":" 2 "}],[{" name ":" Beijing "},{" name ":" Shanghai "," Value ":" 1 "}],
"Success": true,
"Placeslink": [[{"Name": "Beijing"},{"name": "Nanchang"}],[{"name": "Beijing"},{"name": "Chongqing"}],[{"name": "Beijing"},{"name": "Lhasa"}],[{" Name ":" Beijing "},{" name ":" Shanghai "}]}

  

 

  

 

 

JSON format description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.