@Override public ListProperty deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { ObjectMapper mapper = (ObjectMapper) jp.getCodec(); ObjectNode node = mapper.readTree(jp); String nameId = node.fieldNames().next(); Property[] properties = mapper.readValue(node.elements().next().toString().getBytes("UTF-8"), Property[].class); return new ListProperty(nameId, Arrays.asList(properties)); } }
private static Map<String, ArrayProperty> propertyFrom(final String json) { try { final ObjectNode object = (ObjectNode) MAPPER.readTree(json); final String propertyName = object.fieldNames().next(); final JsonNode node = object.elements().next(); final ArrayProperty array = MAPPER.readerFor(Property.class).readValue(node); return Collections.singletonMap(propertyName, array); } catch (final IOException e) { throw new AssertionError("Unable to deserialize given parameter", e); } }
private static Map<String, ArrayProperty> propertyFrom(final String json) { try { final ObjectNode object = (ObjectNode) MAPPER.readTree(json); final String propertyName = object.fieldNames().next(); final JsonNode node = object.elements().next(); final ArrayProperty array = MAPPER.readerFor(Property.class).readValue(node); return Collections.singletonMap(propertyName, array); } catch (final IOException e) { throw new AssertionError("Unable to deserialize given parameter", e); } }
private static Map<String, ArrayProperty> propertyFrom(final String json) { try { final ObjectNode object = (ObjectNode) MAPPER.readTree(json); final String propertyName = object.fieldNames().next(); final JsonNode node = object.elements().next(); final ArrayProperty array = MAPPER.readerFor(Property.class).readValue(node); return Collections.singletonMap(propertyName, array); } catch (final IOException e) { throw new AssertionError("Unable to deserialize given parameter", e); } }