/** * Convenience method that may be used by composite or container deserializers, * for reading one-off values contained (for sequences, it is more efficient * to actually fetch deserializer once for the whole collection). *<p> * NOTE: when deserializing values of properties contained in composite types, * rather use {@link #readPropertyValue(JsonParser, BeanProperty, Class)}; * this method does not allow use of contextual annotations. * * @since 2.4 */ public <T> T readValue(JsonParser p, Class<T> type) throws IOException { return readValue(p, getTypeFactory().constructType(type)); }
@Override public Duration deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { try { return Duration.parse(context.readValue(parser, String.class)); } catch (DateTimeParseException e) { throw new IOException(e); } } }
@Override public NottableString deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) { Boolean not = null; String string = null; while (jsonParser.nextToken() != JsonToken.END_OBJECT) { String fieldName = jsonParser.getCurrentName(); if ("not".equals(fieldName)) { jsonParser.nextToken(); not = jsonParser.getBooleanValue(); } else if ("value".equals(fieldName)) { jsonParser.nextToken(); string = ctxt.readValue(jsonParser, String.class); } } if (StringUtils.isEmpty(string)) { return null; } return string(string, not); } else if (jsonParser.getCurrentToken() == JsonToken.VALUE_STRING || jsonParser.getCurrentToken() == JsonToken.FIELD_NAME) { return string(ctxt.readValue(jsonParser, String.class)); } return null; }
private T deserializeObject(JsonParser jsonParser, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException { T enteries = build(); NottableString key = string(""); while (true) { JsonToken token = jsonParser.nextToken(); switch (token) { case FIELD_NAME: key = string(jsonParser.getText()); break; case START_ARRAY: enteries.withEntry(key, ctxt.readValue(jsonParser, NottableString[].class)); break; case END_OBJECT: return enteries; default: throw new RuntimeException("Unexpected token: \"" + token + "\" id: \"" + token.id() + "\" text: \"" + jsonParser.getText()); } } }
@Override public CloseableIterable<?> deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final JavaType typeReference = ctxt.getTypeFactory() .constructCollectionType(List.class, valueType); return new WrappedCloseableIterable<>(ctxt.<Iterable<?>>readValue(jp, typeReference)); }
private Cookies deserializeObject(JsonParser jsonParser, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException { Cookies cookies = new Cookies(); NottableString key = string(""); while (true) { JsonToken t = jsonParser.nextToken(); switch (t.id()) { case JsonTokenId.ID_FIELD_NAME: key = string(jsonParser.getText()); break; case JsonTokenId.ID_STRING: cookies.withEntry(key, string(ctxt.readValue(jsonParser, String.class))); break; case JsonTokenId.ID_END_OBJECT: return cookies; default: throw new RuntimeException("Unexpected token: \"" + t + "\" id: \"" + t.id() + "\" text: \"" + jsonParser.getText()); } } }
@Override public AWSCredentialsProvider deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { return context.readValue(jsonParser, AWSCredentialsProvider.class); }
@Override public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return deserializationContext.readValue(jsonParser, javaType); } }
@Override public ZonedDateTime deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final String value = deserializationContext.readValue(jsonParser, String.class);//value has the format "JJJJ-mm" return ZonedDateTime.parse(value + "-01T00:00:00.000Z"); } }
@Override public ZonedDateTime deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final String value = deserializationContext.readValue(jsonParser, String.class);//value has the format "JJJJ-mm" final String correctedValue = value.matches("^\\d{4}-\\d{2}$") ? value + "-01T00:00:00.000Z" : value; return ZonedDateTime.parse(correctedValue); } }
@Override public ZonedDateTime deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final String value = deserializationContext.readValue(jsonParser, String.class);//value has the format "JJJJ-mm" final String correctedValue = value.matches("^\\d{4}-\\d{2}$") ? value + "-01T00:00:00.000Z" : value; return ZonedDateTime.parse(correctedValue); } }
@Override public T2 deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { return converter.convert(ctxt.readValue(p, wrapped)); } });
@Override public MonetaryAmount deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final MoneyRepresentation moneyRepresentation = deserializationContext.readValue(jsonParser, MoneyRepresentation.class); final BigDecimal amount = new BigDecimal(moneyRepresentation.getCentAmount()).divide(new BigDecimal(100)); final String currencyCode = moneyRepresentation.getCurrencyCode(); return MoneyImpl.of(amount, currencyCode); } }
private Trace nextTrace(JsonParser p, DeserializationContext ctxt) throws IOException { Trace.Builder traceBuilder = Trace.newBuilder(); p.nextToken(); while (p.currentToken() != JsonToken.END_ARRAY) { traceBuilder.addSpans(ctxt.readValue(p, Span.class)); p.nextToken(); } p.nextToken(); return traceBuilder.build(); } }
@Override public Trace deserialize(JsonParser p, DeserializationContext ctx) throws IOException { Trace.Builder traceBuilder = Trace.newBuilder(); while (p.nextToken() != JsonToken.END_ARRAY) { traceBuilder.addSpans(ctx.readValue(p, Span.class)); } return traceBuilder.build(); } }
@Override @SuppressWarnings("unchecked") public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { JavaType substituteType = deserializationContext.getTypeFactory().constructType(environment.getMappableInputType(detectedType).getType()); Object substitute = deserializationContext.readValue(jsonParser, substituteType); return inputConverter.convertInput(substitute, detectedType, environment, valueMapper); }
@Override public AddressOverview deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { List<Object> propertyList = context.readValue(parser, context.getTypeFactory() .constructCollectionType(ArrayList.class, Object.class)); return toAddressOverview(propertyList); }
@Override public CloseableIterable<?> deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final JavaType typeReference = ctxt.getTypeFactory() .constructCollectionType(List.class, valueType); return new WrappedCloseableIterable<>(ctxt.<Iterable<?>>readValue(jp, typeReference)); }