Iterative parsing of JSON simple instances

Source: Internet
Author: User

Since this problem is encountered in the project, record it here.

For example: The requested JSON string:

1 {2"MSG": "Data acquisition succeeded",3"Success":true,4"Data":[5         {6"id": 40,7"Name": "Art",8"ParentID": 4,9"Photourl": "[email protected]",Ten"Enable": 1, One"POS": 2, A"Visiturl": "Syspxbpage", -"Ord": 0, -"Related": "1", the"Moduletype": "", -"Catelist":[ -                 { -"ID": 155, +"ModuleID": 40, -"Name": "Sculpture", +"Photourl": "Syspxbpage/artpage/[email protected]", A"Enable": 1, at"Createtime": 1508498216000 -                 } -             ] -         }, -         { -"id": 41, in"Name": "Calligraphy", -"ParentID": 4, to"Photourl": "[email protected]", +"Enable": 1, -"POS": 2, the"Visiturl": "Syspxbpage", *"Ord": 0, $"Related": "1",Panax Notoginseng"Moduletype": "", -"Catelist":[ the                 { +"ID": 158, A"ModuleID": 41, the"Name": "The inscription", +"Photourl": "Syspxbpage/writingpage/[email protected]", -"Enable": 1, $"Createtime": 1508498326000 $                 } -             ] -         } the}

For example: Get the value of Photourl:

Jsonobject da = resultjson.getjsonobject ("Data");

Jsonarray d = da. Jsonarray ("Catelist");

Jsonobject ob = (jsonobject) d.get (0); Here is the first object to get

String result = ob.getstring ("Photourl");

If you get the value of success:

Resultjson.getbooleanvalue ("Success");

Iterative parsing of JSON simple instances

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.