Java Code Examples for javax.json.JsonPointer#getValue()
The following examples show how to use
javax.json.JsonPointer#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserView.java From javaee8-cookbook with Apache License 2.0 | 7 votes |
private void loadFromStructure() { JsonStructure structure = BUILDERFACTORY.createObjectBuilder() .add("name", "User1") .add("email", "[email protected]") .add("profiles", BUILDERFACTORY.createArrayBuilder() .add(BUILDERFACTORY.createObjectBuilder() .add("id", "1") .add("name", "Profile1")) .add(BUILDERFACTORY.createObjectBuilder() .add("id", "2") .add("name", "Profile2"))) .build(); fromStructure = jsonbBuilder.toJson(structure); JsonPointer pointer = Json.createPointer("/profiles"); JsonValue value = pointer.getValue(structure); fromJpointer = value.toString(); }
Example 2
Source File: JsonpTest.java From ee8-sandbox with Apache License 2.0 | 6 votes |
@Test public void testJsonPointer() { JsonReader reader = Json.createReader(JsonpTest.class.getResourceAsStream("/persons.json")); JsonArray arrays = reader.readArray(); JsonPointer p = Json.createPointer("/0/name"); JsonValue name = p.getValue(arrays); System.out.println("json value ::" + name); // assertEquals("Duke", name.toString()); JsonReader objReader = Json.createReader(JsonpTest.class.getResourceAsStream("/person.json")); JsonPointer p2 = Json.createPointer("/name"); JsonValue name2 = p2.getValue(objReader.readObject()); System.out.println("json value ::" + name2); // assertEquals("Duke", name2.toString()); }
Example 3
Source File: JPointer.java From javaee8-cookbook with Apache License 2.0 | 5 votes |
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); } }
Example 4
Source File: JsonPointerCrud.java From tutorials with MIT License | 4 votes |
public String fetchValueFromKey(String key) { JsonPointer jsonPointer = Json.createPointer("/" + key); JsonString jsonString = (JsonString) jsonPointer.getValue(jsonStructure); return jsonString.getString(); }
Example 5
Source File: JsonPointerCrud.java From tutorials with MIT License | 4 votes |
public String fetchListValues(String key) { JsonPointer jsonPointer = Json.createPointer("/" + key); JsonObject jsonObject = (JsonObject) jsonPointer.getValue(jsonStructure); return jsonObject.toString(); }
Example 6
Source File: JsonPointerCrud.java From tutorials with MIT License | 3 votes |
public JsonStructure delete(String key) { JsonPointer jsonPointer = Json.createPointer("/" + key); jsonPointer.getValue(jsonStructure); jsonStructure = jsonPointer.remove(jsonStructure); return jsonStructure; }
Example 7
Source File: JsonPointerCrud.java From tutorials with MIT License | 3 votes |
public String fetchFullJSON() { JsonPointer jsonPointer = Json.createPointer(""); JsonObject jsonObject = (JsonObject) jsonPointer.getValue(jsonStructure); return jsonObject.toString(); }