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