Skip to content

Instantly share code, notes, and snippets.

@rashkur
Created March 10, 2018 00:08
Show Gist options
  • Save rashkur/cb44fe5188e393c65ab277c9c65edfc7 to your computer and use it in GitHub Desktop.
Save rashkur/cb44fe5188e393c65ab277c9c65edfc7 to your computer and use it in GitHub Desktop.
java jakson json read subnodes
{
"address" : { "street" : "2940 5th Ave", "zip" : 980021 },
"dimensions" : [ 10.0, 20.0, 15.0 ]
}
JsonNode root = mapper.readTree(src);
int zip =root.at("/address/zip").asIntValue();
double height = root.add("/dimensions/1").asDoubleValue();// assuming it's the second number in there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment