Skip to content

Instantly share code, notes, and snippets.

@markito
Created May 18, 2012 14:27
Show Gist options
  • Save markito/2725535 to your computer and use it in GitHub Desktop.
Save markito/2725535 to your computer and use it in GitHub Desktop.
JSON Streaming API
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = mapper.readValue(jsonResponse, Map.class);
LinkedHashMap<String, Object> linkedMap = (LinkedHashMap) map.get("body");
LinkedHashMap<String, Object> serverValues = (LinkedHashMap) linkedMap.get("item");
if (serverValues == null) {
ArrayList list = (ArrayList) linkedMap.get("items");
LOGGER.info(list);
} else {
Iterator it = serverValues.keySet().iterator();
if (it != null) {
while (it.hasNext()) {
String key = (String) it.next();
LOGGER.info(key + ":" + serverValues.get(key));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment