<dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> json { "age": 25, "email": "xiaoming@example.com" } import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; JSONParser parser = new JSONParser(); try { JSONObject jsonObject = (JSONObject) parser.parse(jsonString); String name = (String) jsonObject.get("name"); int age = ((Long) jsonObject.get("age")).intValue(); String email = (String) jsonObject.get("email"); } catch (ParseException e) { e.printStackTrace(); }


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