import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; public class JSONExample { public static void main(String[] args) throws JSONException { JSONObject jsonObject = new JSONObject(); jsonObject.put("name", "John"); jsonObject.put("age", 25); jsonObject.put("email", "john@example.com"); String jsonString = jsonObject.toString(); System.out.println(jsonString); JSONObject parsedObject = new JSONObject(jsonString); String name = parsedObject.getString("name"); int age = parsedObject.getInt("age"); String email = parsedObject.getString("email"); System.out.println("Name: " + name); System.out.println("Age: " + age); System.out.println("Email: " + email); } }


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