回覆列表
  • 1 # 哦嗚URL哈佛

    好像沒有什麼特別的辦法,可能是我才疏學淺,

    我知道的兩種方式:

    map是鍵值對存在,那麼型別都是固定的,我們可以再申請個map<String ,String>遍歷替換原來的map再轉換成json字串

    字串替換,用正則新增雙引號:

    public void testJson(){ Map<String,Integer> map = new HashMap<String,Integer>(); map.put("aaa", 111); String json = JSON.toJSONString(map); String json1 = json.replaceAll(":", ":\""); json1 = json1.replaceAll("}", "\"}"); System.out.println(json); System.out.println(json1);}

  • 中秋節和大豐收的關聯?
  • 朝花夕拾五猖會主要內容是什麼?