问答详情
源自:3-2 使用Map 构建JSON

你好,这个报错如何解决?

https://img.mukewang.com/5bab72080001574604850228.jpg代码如下:

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());

}

}

}


提问者:Jess001 2018-09-26 19:49

个回答

  • 清晚惘游
    2018-10-08 11:55:03
    已采纳

    没有引入json 包吧