<dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> json { "age": 25, } import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public class JSONParserDemo { public static void main(String[] args) { JSONParser parser = new JSONParser(); try { JSONObject json = (JSONObject) parser.parse(jsonString); String name = (String) json.get("name"); Long age = (Long) json.get("age"); String city = (String) json.get("city"); } catch (ParseException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文