How to iterate a JSONObject (gson)
问题 I have a JsonObject e.g JsonObject jsonObject = {"keyInt":2,"keyString":"val1","id":"0123456"} Every JSONObject contains a "id" entry, but th number of other key/value pairs is NOT determined, so I want to create create an object with 2 attributes: class myGenericObject { Map<String, Object> attributes; String id; } So I want my attributes map to look like this: "keyInt" -> 4711 "keyStr" -> "val1" I found this solution Map<String, Object> attributes = new HashMap<String, Object>(); Set<Entry