http://code.google.com/p/json-simple/
System.out.println("=======decode=======");
String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
Object obj=JSONValue.parse(s);
JSONArray array=(JSONArray)obj;
System.out.println("======the 2nd element of array======");
System.out.println(array.get(1));
JSONObject me = array.optJSONObject(0);
JSONObject fbook = new JSONObject(s);
fbook.get("namestring");
//Manage JSON String={\"4\":[5,{\"6\":7}]};
public Map parseJSONStr(String jsonText) {
JSONParser parser = new JSONParser();
ContainerFactory containerFactory = new ContainerFactory() {
public List creatArrayContainer() {
return new LinkedList();
}
public Map createObjectContainer() {
return new LinkedHashMap();
}
};
try {
Map json = (Map) parser.parse(jsonText, containerFactory);
return json;
// Iterator iter = json.entrySet().iterator();
// while(iter.hasNext()){
// Map.Entry entry = (Map.Entry)iter.next();
// }
} catch (ParseException pe) {
System.out.println(pe);
}
return null;
}
Java - Json
Related Posts:
Javascipt to UML DiagramJSUML http://jsuml.gaertner-network.de/ … Read More
Starling FrameworkStarling is a pure ActionScript 3 library for Adobe Flash. It recreates Flash's display list architecture on the GPU — providing a performance unlike anything before! Starling runs in the browser and… Read More
Eclipse - UML PlugginIf you're a designer then Papyrus is your best choice it's very advanced and full of features, but if you just want to sketch out some uml diagrams and easy installation then ObjectAid is pretty cool and it doesn't require… Read More
Vaadin - TouchKitCreating a Vaadin Touhckit Project with the Maven Archetype mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-touchkit -DarchetypeVersion=3.0.0-beta1 -DgroupId=org.configurator.mobil… Read More
Java - Generate Image from Google MapsBeside this API, Google Maps also provides an URL based API for extracting static Google Maps directly into desktop application, without requiring JavaScript or access keys. This API is very well explained here: http://cod… Read More
0 comments:
Post a Comment