Java 类javax.json.JsonPointer 实例源码

项目:javaee8-applications    文件:CustomerController.java   
public void findCustomerByAddress() {
    searchResult = null;
    String text = "/" + this.addressSearchText;
    JsonObject json = Json.createObjectBuilder().build();
    JsonValue object = json.getJsonObject(fetchJson());
    if (addressSearchText != null) {
        JsonPointer pointer = Json.createPointer(text);
        JsonValue result = pointer.getValue(object.asJsonArray());

        // Replace a value
        JsonArray array = (JsonArray) pointer.replace(object.asJsonArray(), Json.createValue("1000 JsonP Drive"));
        searchResult = array.toString();
        //searchResult = result.toString();
    }

}
项目:ee8-sandbox    文件:JsonpTest.java   
@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());
}
项目:johnzon    文件:JsonProviderImpl.java   
@Override
public JsonPointer createPointer(String path) {
    return DELEGATE.createPointer(path);
}
项目:johnzon    文件:JsonProviderImpl.java   
@Override
public JsonPointer createPointer(String path) {
    return new JsonPointerImpl(path);
}