/**
* <pre>
* {
* "id": 2,
* "title": "JSON title",
* "Config": {
* "width": 34,
* "Height": 35
* },
* "Data": [
* "JAVA",
* "JavaScript",
* "PHP"
* ]
* }
* </pre>
*
* @param args
*/
public static void Main (string[] args)
{
System.out.println ("----------------------------");
String jsonstr = "{\" id\ ": 2," + "\" title\ ": \" JSON title\ "," + "\" config\ ": {" + "\" width\ ": 34,"
+ "\" height\ ":", "+"}, \ "Data\": ["+" \ "Java\", \ "javascript\", \ "php\" "+"]} ";
System.out.println (JSONSTR);
System.out.println ("----------------------------");
Jsonobject ob = Jsonobject.parseobject (JSONSTR);
set<string> Obkeys = Ob.keyset ();
for (String Key:obkeys)
{
SYSTEM.OUT.PRINTLN (key + ":" + ob.getstring (key));
}
System.out.println ("----------------------------");
System.out.println (Ob.values ());
Jsonobject config = (jsonobject) ob.get ("config");
set<string> Configkeys = Config.keyset ();
for (String Key:configkeys)
{
SYSTEM.OUT.PRINTLN (key + ":" + config.getbytevalue (key));
}
System.out.println ("----------------------------");
Jsonarray array = (Jsonarray) ob.get ("Data");
Listiterator<object> it = Array.listiterator ();
while (It.hasnext ())
{
System.out.println (It.next ());
}
System.out.println ("----------------------------");
}
Parsing Jason Data