Jess001
2018-09-26 19:49
代码如下:
package json;
import java.io.File;
public class JsonObjectSample {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
private static void jSONObjectSample(){
JSONObject wangxiaoer = new JSONObject();
Object nullObj = null;
try{
wangxiaoer.put("name","王小二");
wangxiaoer.put("age",25.2);
System.out.println(wangxiaoer.toString());
}catch(JSONException e){
e.printStackTrace();
}
}
private static void createJsonByMap(){
Map<String,Object> wangxiaoer = new HashMap<String,Object>
wangxiaoer.put("name","王小二");
wangxiaoer.put("age",25.2);
System.out.println(new JSONObject(wangxiaoer).toString());
}
}
}
没有引入json 包吧
JSON快速入门(Java版)
102037 学习 · 163 问题
相似问题