{ "name": "John", "age": 30, "isStudent": true } import org.json.JSONObject; String jsonString = "{\"name\":\"John\",\"age\":30,\"isStudent\":true}"; JSONObject jsonObject = new JSONObject(jsonString); String name = jsonObject.getString("name"); int age = jsonObject.getInt("age"); boolean isStudent = jsonObject.getBoolean("isStudent"); System.out.println("Name: " + name); System.out.println("Age: " + age); System.out.println("Is Student: " + isStudent); import org.json.JSONObject; JSONObject jsonObject = new JSONObject(); jsonObject.put("name", "John"); jsonObject.put("age", 30); jsonObject.put("isStudent", true); String jsonString = jsonObject.toString(); System.out.println(jsonString);


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