public static Attribute of(final String name, final Object value) { final JsonNode jsonNode = JsonUtils.newObjectMapper().valueToTree(value); return of(name, jsonNode); }
@Override public AttributeDefinition deserialize(final JsonParser jsonParser, final DeserializationContext context) throws IOException { final JsonNode jsonNode = jsonParser.<JsonNode>readValueAsTree(); final String name = extractNameFromJson(jsonNode); final Class<? extends AttributeDefinition> clazz = findClassForTypeName(name); //the jsonParser is not reusable after reading a value from it, so an object mapper needs to transform the JSON return JsonUtils.newObjectMapper().treeToValue(jsonNode, clazz); }
@Override public AttributeDefinition deserialize(final JsonParser jsonParser, final DeserializationContext context) throws IOException { final JsonNode jsonNode = jsonParser.<JsonNode>readValueAsTree(); final String name = extractNameFromJson(jsonNode); final Class<? extends AttributeDefinition> clazz = findClassForTypeName(name); //the jsonParser is not reusable after reading a value from it, so an object mapper needs to transform the JSON return JsonUtils.newObjectMapper().treeToValue(jsonNode, clazz); }