How to iterate a JsonObject (gson)

前端 未结 5 1149
有刺的猬
有刺的猬 2021-02-19 08:50

I have a JsonObject e.g

JsonObject jsonObject = {\"keyInt\":2,\"keyString\":\"val1\",\"id\":\"0123456\"}

Every JsonObject contains

5条回答
  •  我在风中等你
    2021-02-19 09:36

    replace "" with blank.

       Map attributes = new HashMap();
       Set> entrySet = jsonObject.entrySet();
       for(Map.Entry entry : entrySet){
        if (! nonProperties.contains(entry.getKey())) {
          properties.put(entry.getKey(), jsonObject.get(entry.getKey()).replace("\"",""));
        }
       }
    

提交回复
热议问题