Search in sources :

Example 1 with RawValue

use of com.fasterxml.jackson.databind.util.RawValue in project jackson-databind by FasterXML.

the class TestJsonNode method testRawValue.

// [databind#743]
public void testRawValue() throws Exception {
    ObjectNode root = MAPPER.createObjectNode();
    root.putRawValue("a", new RawValue(new SerializedString("[1, 2, 3]")));
    assertEquals("{\"a\":[1, 2, 3]}", MAPPER.writeValueAsString(root));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) RawValue(com.fasterxml.jackson.databind.util.RawValue)

Example 2 with RawValue

use of com.fasterxml.jackson.databind.util.RawValue in project jackson-databind by FasterXML.

the class RawValueTest method testRawFromMapToTree.

// for [databind#743]
public void testRawFromMapToTree() throws Exception {
    RawValue myType = new RawValue("Jackson");
    Map<String, Object> object = new HashMap<String, Object>();
    object.put("key", myType);
    JsonNode jsonNode = MAPPER.valueToTree(object);
    String json = MAPPER.writeValueAsString(jsonNode);
    assertEquals("{\"key\":Jackson}", json);
}
Also used : HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) RawValue(com.fasterxml.jackson.databind.util.RawValue)

Aggregations

RawValue (com.fasterxml.jackson.databind.util.RawValue)2 SerializedString (com.fasterxml.jackson.core.io.SerializedString)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1