java中使用json以及所导入的包

导入6个jar包,下载地址:https://github.com/joytom/json_all
java中使用json以及所导入的包_第1张图片

		JSONObject wang = new JSONObject();
		Object nullObj = null;
		wang.put("name","王小二");
		wang.put("age","25.2");
		wang.put("birthday","1998-12-07");
		wang.put("major",new String[] {"理发","挖掘机"});
		wang.put("has_girfriend",false);
		wang.put("car",nullObj);
		System.out.println(wang.toString());

输出结果:

{
	"birthday":"1998-12-07",
	"has_girfriend":false,
	"major":["理发","挖掘机"],
	"name":"王小二",
	"age":"25.2"
}

你可能感兴趣的:(JavaJson)