List of usage examples for com.fasterxml.jackson.databind.node NullNode getInstance
public static NullNode getInstance()
From source file:com.almende.eve.rpc.jsonrpc.jackson.JsonNullAwareDeserializer.java
@Override public JsonNode getNullValue() { return NullNode.getInstance(); }
From source file:com.spotify.hamcrest.jackson.IsJsonNullTest.java
@Test public void testType() throws Exception { final Matcher<JsonNode> sut = jsonNull(); assertThat(NullNode.getInstance(), is(sut)); }
From source file:com.spotify.hamcrest.jackson.IsJsonNullTest.java
@Test public void testMatch() throws Exception { final Matcher<JsonNode> sut = jsonNull(); assertThat(NullNode.getInstance(), is(sut)); }
From source file:com.redhat.lightblue.util.JsonObjectTest.java
/** * Test of getSourceNode method, of class JsonObject. *//* ww w . jav a 2s .co m*/ @Test public void testGetSourceNode() { JsonNode expResult = NullNode.getInstance(); JsonObject instance = new JsonObjectImpl(expResult); JsonNode result = instance.getSourceNode(); assertEquals(expResult, result); }
From source file:com.baasbox.commands.ScriptsResource.java
private static JsonNode event(JsonNode command, JsonCallback callback) throws CommandException { //todo implement public events? return NullNode.getInstance(); }
From source file:com.squarespace.template.GeneralUtilsTest.java
@Test public void testIfString() { // Truth-y values JsonNode node = new IntNode(123); assertEquals(GeneralUtils.ifString(node, "000"), "123"); node = new TextNode("456"); assertEquals(GeneralUtils.ifString(node, "000"), "456"); // False-y values node = new IntNode(0); assertEquals(GeneralUtils.ifString(node, "000"), "000"); node = NullNode.getInstance(); assertEquals(GeneralUtils.ifString(node, "000"), "000"); }
From source file:net.javacrumbs.jsonunit.core.internal.Jackson2NodeFactory.java
@Override protected Node nullNode() { return newNode(NullNode.getInstance()); }
From source file:com.redhat.lightblue.util.JsonObjectTest.java
/** * Test of toJson method, of class JsonObject. *///w w w.ja v a2 s. co m @Test public void testToJson() { JsonObject instance = new JsonObjectImpl(); JsonNode expResult = NullNode.getInstance(); JsonNode result = instance.toJson(); assertEquals(expResult, result); }
From source file:com.vaporwarecorp.mirror.util.JsonUtil.java
public static JsonNode toJsonNode(String jsonString) { try {//from w w w .j a v a 2 s .co m return objectMapper.readTree(jsonString); } catch (IOException e) { Timber.e(e, "Error parsing toJsonNode"); return NullNode.getInstance(); } }
From source file:com.flipkart.zjsonpatch.JsonPatch.java
private static void process(JsonNode patch, JsonPatchProcessor processor, EnumSet<CompatibilityFlags> flags) throws InvalidJsonPatchException { if (!patch.isArray()) throw new InvalidJsonPatchException("Invalid JSON Patch payload (not an array)"); Iterator<JsonNode> operations = patch.iterator(); while (operations.hasNext()) { JsonNode jsonNode = operations.next(); if (!jsonNode.isObject()) throw new InvalidJsonPatchException("Invalid JSON Patch payload (not an object)"); Operation operation = Operation .fromRfcName(getPatchAttr(jsonNode, Constants.OP).toString().replaceAll("\"", "")); List<String> path = getPath(getPatchAttr(jsonNode, Constants.PATH)); switch (operation) { case REMOVE: { processor.remove(path);/*ww w .j a v a 2 s.c o m*/ break; } case ADD: { JsonNode value; if (!flags.contains(CompatibilityFlags.MISSING_VALUES_AS_NULLS)) value = getPatchAttr(jsonNode, Constants.VALUE); else value = getPatchAttrWithDefault(jsonNode, Constants.VALUE, NullNode.getInstance()); processor.add(path, value); break; } case REPLACE: { JsonNode value; if (!flags.contains(CompatibilityFlags.MISSING_VALUES_AS_NULLS)) value = getPatchAttr(jsonNode, Constants.VALUE); else value = getPatchAttrWithDefault(jsonNode, Constants.VALUE, NullNode.getInstance()); processor.replace(path, value); break; } case MOVE: { List<String> fromPath = getPath(getPatchAttr(jsonNode, Constants.FROM)); processor.move(fromPath, path); break; } } } }