hashmap構(gòu)建json對(duì)象,輸出時(shí)出現(xiàn)語(yǔ)法錯(cuò)誤
為何我的使用hashmap構(gòu)建json對(duì)象時(shí),在System.out.println(new JSONObject(json).toString());出現(xiàn)語(yǔ)法錯(cuò)誤,提示The constructor JSONObject(Map<String,Object>) is undefined未定義。。。
為何我的使用hashmap構(gòu)建json對(duì)象時(shí),在System.out.println(new JSONObject(json).toString());出現(xiàn)語(yǔ)法錯(cuò)誤,提示The constructor JSONObject(Map<String,Object>) is undefined未定義。。。
2017-11-27
舉報(bào)
2018-02-15
試試System.out.println(new JSONObject().fromObject(json).toString());
2017-11-28
JSONObject這個(gè)類的構(gòu)造方法里沒(méi)有參數(shù)為Map的構(gòu)造方法
System.out.println(json.toString());這樣應(yīng)該就對(duì)了