67,550
社区成员




public String createJson(){
try{
JSONObject jsonObject=new JSONObject();
jsonObject.put("id","1");
jsonObject.put("name","李磊");
jsonObject.put("age",30);
return jsonObject.toString();
}catch(Exception e){
e.printStackTrace();
}
return "";
}
public String createJson(){
JSONObject jsonObject=null;
try{
jsonObject=new JSONObject();
jsonObject.put("id","1");
jsonObject.put("name","李磊");
jsonObject.put("age",30);
}catch(Exception e){
e.printStackTrace();
}
return null!=jsonObject?jsonObject.toString():"";
}
也可以这么写,估计好理解点