package com.dxy.study_0628.study.json; import org.json.JSONException; import org.json.JSONObject; import java.util.HashMap; public class JsonStudy { public static void main(String[] args) { JSONObject zhangsan = new JSONObject(); try { //添加 zhangsan.put("name", "张三"); zhangsan.put("age", 18.4); zhangsan.put("birthday", "1900-20-03"); zhangsan.put("majar", new String[] {"哈哈","嘿嘿"}); zhangsan.put("null", "null"); zhangsan.put("house", false); System.out.println(zhangsan.toString()); } catch (JSONException e) { e.printStackTrace(); } HashMapzhangsan1 = new HashMap<>(); zhangsan1.put("name", "张三"); zhangsan1.put("age", 18.4); zhangsan1.put("birthday", "1900-20-03"); zhangsan1.put("majar", new String[] {"哈哈","嘿嘿"}); zhangsan1.put("null", null); zhangsan1.put("house", false); System.out.println(new JSONObject(zhangsan1).toString()); } }
https://blog.csdn.net/u012448904/article/details/84292821
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)