use of org.apache.flink.shaded.jackson2.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));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.util.RawValue in project flink by apache.
the class JsonObjectAggFunction method getValue.
@Override
public String getValue(Accumulator acc) {
final ObjectNode rootNode = createObjectNode();
try {
for (final StringData key : acc.map.keys()) {
final StringData value = acc.map.get(key);
final JsonNode valueNode = value == null ? NULL_NODE : getNodeFactory().rawValueNode(new RawValue(value.toString()));
rootNode.set(key.toString(), valueNode);
}
} catch (Exception e) {
throw new TableException("The accumulator state could not be serialized.", e);
}
return serializeJson(rootNode);
}
use of org.apache.flink.shaded.jackson2.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);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.util.RawValue in project flink by apache.
the class JsonArrayAggFunction method getValue.
@Override
public String getValue(Accumulator acc) {
final ArrayNode rootNode = createArrayNode();
try {
for (final StringData item : acc.list.get()) {
final JsonNode itemNode = getNodeFactory().rawValueNode(new RawValue(item.toString()));
rootNode.add(itemNode);
}
} catch (Exception e) {
throw new TableException("The accumulator state could not be serialized.", e);
}
return serializeJson(rootNode);
}
Aggregations