import org.json.*; public class JSONExample { public static void main(String[] args) { JSONObject jsonObject = new JSONObject(); jsonObject.put("name", "John"); jsonObject.put("age", 25); jsonObject.put("city", "New York"); String jsonString = jsonObject.toString(); System.out.println("JSON String: " + jsonString); JSONObject newJsonObject = new JSONObject(jsonString); System.out.println("Name: " + newJsonObject.getString("name")); System.out.println("Age: " + newJsonObject.getInt("age")); System.out.println("City: " + newJsonObject.getString("city")); } }


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