Some processing of JSON data in Java

Source: Internet
Author: User


Related treatment of Jsonobject


-------------the key to traverse the JSON string-----------jsonobject data = jsonobject.fromobject ("{\" cill\ ": \" 2\ ", \ "age\": \ "Huang Lei \"} "); Iterator keys = data.keys (); Arraylist<string> listkey = new arraylist<string> ();while  (Keys.hasNext () )  {string key = keys.next (). toString (); Listkey.add (key);} --------ArrayList to string [ ] ---------string[] array =  (string[])   Listkey.toarray (New string[listkey.size ()));//-----The order of the initials in the String array   a- z   --- ------The static ordering method of the//  call array sort, and is not case sensitive arrays.sort (array, string.case_insensitive_order); Stringbuffer paramvalue = new stringbuffer ();for  (String key : array)  {string value = data.getstring (Key);p aramvalue.append (value);} -----The JSON data to delete an element  ---------Jsonobject.remove ("key");//-----Three ways to create an array--------- public static  void main (String[] aRGS) {  //First type          int[] temp = { 3,5,6,7,9,4,1,21,36,0};           //Second Type          int [] temp1 = new int[3];           temp1[0]=1;           temp1[1]=1;          temp1[2]=1;            //Third Kind of         int  vec[] = new int[]{1, 5, 3};         }   



This article is from the "Jianbo" blog, make sure to keep this source http://jianboli.blog.51cto.com/12075002/1889497

Some processing of JSON data in Java

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.