April 2018
Intermediate to advanced
382 pages
10h 11m
English
{ "user": { "email": "elder@eldermoraes.com", "name": "Elder", "profile": [ { "id": 1 }, { "id": 2 }, { "id": 3 } ] }}
public class JPointer { public static void main(String[] args) throws IOException{ try (InputStream is = JPointer.class.getClassLoader().getResourceAsStream("user.json"); JsonReader jr = Json.createReader(is)) { JsonStructure js = jr.read(); JsonPointer jp = Json.createPointer("/user/profile"); JsonValue jv = jp.getValue(js); System.out.println("profile: " + jv); } }}
The execution of this code prints the following:
profile: [{"id":1},{"id":2},{"id":3}]
Read now
Unlock full access