Fastjson--jsonobject and Jsonarray conversion

Source: Internet
Author: User

Fastjson parsing:
Resultvalue=
[
{
"Total": 1,
"Salelists": [
{
"CategoryInfo": "Test parent category",
"id": 12,
"Vendor_code": 0,
"Brandinfo": "Non-dragon brand,",
}
]
}
]
First step: After parsing is complete< span class= "keyword" >< span class= "comment" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >{"total": 1, "salelists": [{"CategoryInfo": "Test parent category", "id": "Vendor_code": 0, "Brandinfo": "Non-dragon brand, ",}]}
     Jsonobject Js=json.parseobject (Json.parsearray (Resultvalue). Get (0). toString ());

Step two: After parsing is complete< span class= "keyword" >< span class= "comment" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >[{"categoryinfo": "Test parent category", "id": 0, "Vendor_code": "Brandinfo": "Non-dragon Brand,",}]

     Jsonarray Js2=json.parsearray (js.getstring ("salelists"). toString ());

Step three: After parsing is complete< span class= "keyword" >< span class= "comment" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >{"categoryinfo": "Test parent category", "id": 0, "Vendor_code": "Non-dragon brand," ","

     Jsonobject Jsobj2=json.parseobject (js2.get (0). toString ());

Fourth step: js2jsobj2.getstring ("id"), get 12

< span class= "keyword" >< span class= "keyword" >< span class= "keyword" >< span class= "comment" >< span class= "keyword" >< span class= "keyword" >        

Fastjson--jsonobject and Jsonarray conversions

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.