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