import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import com.alibaba.fastjson.serializer.SerializerFeature; public class App { public static void main(String[] args) { JSONObject jsonObject = JSONObject.parseObject("{\"name\":\"John\", \"age\":20}"); String name = jsonObject.getString("name"); int age = jsonObject.getIntValue("age"); System.out.println("Name: " + name); System.out.println("Age: " + age); JSONObject json = new JSONObject(); json.put("name", "John"); json.put("age", 20); String jsonString = json.toJSONString(); System.out.println("JSON String: " + jsonString); } }


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