<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
2017-09-24
这样就不会错了。
private static void mapJson(){
Map<String,Object> jo=new HashMap<String,Object>();
jo.put("car", null);
jo.put("girl",new String[]{"张柏芝","张靓颖"});
JSONObject js=new JSONObject();
js.putAll(jo);
System.out.println(js);}
private static void mapJson(){
Map<String,Object> jo=new HashMap<String,Object>();
jo.put("car", null);
jo.put("girl",new String[]{"张柏芝","张靓颖"});
JSONObject js=new JSONObject();
js.putAll(jo);
System.out.println(js);}
2017-09-19
最赞回答 / 幸福是可积的
maven的目录结构只是为了便于代码的管理,写路径时还是以包名为相对路径,
例如
你写的wangxiao.json不属于任何包,那就是在项目根目录下,直接写wangxiao.json就可以了。
如果你有一个包com.imooc.json,而且你的wangxiao.json在该包下,那么你要写成com/imooc/json/wangxiao.json
2017-09-08