JSONObject jsonObject = new JSONObject(); jsonObject.put("name", "John"); jsonObject.put("age", 30); jsonObject.put("isMarried", true);
String jsonString = "{ \"name\":\"John\", \"age\":30, \"isMarried\":true }"; JSONObject jsonObject = new JSONObject(jsonString);
String name = jsonObject.getString("name"); int age = jsonObject.getInt("age"); boolean isMarried = jsonObject.getBoolean("isMarried");Overall, the org.json package library is useful for dealing with JSON data in Java, and the JSONObject class provides a convenient way to work with JSON objects.