本文主要是介绍net.sf.json.JSONObject在参数为空时,返回json中没有这个key,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用net.sf.json.JSONObject
实例:
Person person = new Person();
person.setAge(14);
person.setSex(“Female”);
person.setAddress(“”);
person.setName(“小戏”);
JSONObject tempJson = new JSONObject();
tempJson.put(“name”,person.getName() );
tempJson.put(“age”, person.getAge());
tempJson.put(“address”, person.getAdress());
System.out.println(tempJson.toString());
{“name”:”张云凤”,”age”:14}
在参数为空时,返回的string中没有address值!
这篇关于net.sf.json.JSONObject在参数为空时,返回json中没有这个key的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!