@Override public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException { switch (parser.getCurrentToken()) { case START_ARRAY: if (parser.nextToken() == JsonToken.END_ARRAY) { return null; } int year = parser.getIntValue(); parser.nextToken(); int month = parser.getIntValue(); parser.nextToken(); int day = parser.getIntValue(); if (parser.nextToken() != JsonToken.END_ARRAY) { throw context.wrongTokenException(parser, JsonToken.END_ARRAY, "Expected array to end."); } return LocalDate.of(year, month, day); case VALUE_STRING: String string = parser.getText().trim(); if (string.length() == 0) { return null; } return LocalDate.parse(string, ISO_DATE_OPTIONAL_TIME); } throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string."); }
protected final String _locateTypeId( JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException { if (!paramJsonParser.isExpectedStartArrayToken()) { if (this._defaultImpl != null) { return this._idResolver.idFromBaseType(); } throw paramDeserializationContext.wrongTokenException( paramJsonParser, JsonToken.START_ARRAY, "need JSON Array to contain As.WRAPPER_ARRAY type information for class " + baseTypeName()); } if (paramJsonParser.nextToken() == JsonToken.VALUE_STRING) { paramDeserializationContext = paramJsonParser.getText(); paramJsonParser.nextToken(); return paramDeserializationContext; } if (this._defaultImpl != null) { return this._idResolver.idFromBaseType(); } throw paramDeserializationContext.wrongTokenException( paramJsonParser, JsonToken.VALUE_STRING, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")"); }
private final Object _deserialize( JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException { Object localObject1; if (paramJsonParser.canReadTypeId()) { localObject1 = paramJsonParser.getTypeId(); if (localObject1 != null) { paramJsonParser = _deserializeWithNativeTypeId( paramJsonParser, paramDeserializationContext, localObject1); } } do { boolean bool; Object localObject2; do { return paramJsonParser; bool = paramJsonParser.isExpectedStartArrayToken(); String str = _locateTypeId(paramJsonParser, paramDeserializationContext); localObject2 = _findDeserializer(paramDeserializationContext, str); localObject1 = paramJsonParser; if (this._typeIdVisible) { localObject1 = paramJsonParser; if (paramJsonParser.getCurrentToken() == JsonToken.START_OBJECT) { localObject1 = new TokenBuffer(null, false); ((TokenBuffer) localObject1).writeStartObject(); ((TokenBuffer) localObject1).writeFieldName(this._typePropertyName); ((TokenBuffer) localObject1).writeString(str); localObject1 = JsonParserSequence.createFlattened( ((TokenBuffer) localObject1).asParser(paramJsonParser), paramJsonParser); ((JsonParser) localObject1).nextToken(); } } localObject2 = ((JsonDeserializer) localObject2) .deserialize((JsonParser) localObject1, paramDeserializationContext); paramJsonParser = (JsonParser) localObject2; } while (!bool); paramJsonParser = (JsonParser) localObject2; } while (((JsonParser) localObject1).nextToken() == JsonToken.END_ARRAY); throw paramDeserializationContext.wrongTokenException( (JsonParser) localObject1, JsonToken.END_ARRAY, "expected closing END_ARRAY after type information and deserialized value"); }
@Override public OffsetTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { if (parser.hasToken(JsonToken.VALUE_STRING)) { String string = parser.getText().trim(); if (string.length() == 0) { return null; } try { return OffsetTime.parse(string, _formatter); } catch (DateTimeException e) { _rethrowDateTimeException(parser, context, e, string); } } if (!parser.isExpectedStartArrayToken()) { if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) { return (OffsetTime) parser.getEmbeddedObject(); } throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string."); } int hour = parser.nextIntValue(-1); if (hour == -1) { JsonToken t = parser.getCurrentToken(); if (t == JsonToken.END_ARRAY) { return null; } if (t != JsonToken.VALUE_NUMBER_INT) { _reportWrongToken(parser, context, JsonToken.VALUE_NUMBER_INT, "hours"); } hour = parser.getIntValue(); } int minute = parser.nextIntValue(-1); if (minute == -1) { JsonToken t = parser.getCurrentToken(); if (t == JsonToken.END_ARRAY) { return null; } if (t != JsonToken.VALUE_NUMBER_INT) { _reportWrongToken(parser, context, JsonToken.VALUE_NUMBER_INT, "minutes"); } minute = parser.getIntValue(); } int partialSecond = 0; int second = 0; if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) { second = parser.getIntValue(); if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) { partialSecond = parser.getIntValue(); if (partialSecond < 1_000 && !context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { partialSecond *= 1_000_000; // value is milliseconds, convert it to nanoseconds } parser.nextToken(); } } if (parser.getCurrentToken() == JsonToken.VALUE_STRING) { OffsetTime t = OffsetTime.of(hour, minute, second, partialSecond, ZoneOffset.of(parser.getText())); if (parser.nextToken() != JsonToken.END_ARRAY) { _reportWrongToken(parser, context, JsonToken.END_ARRAY, "timezone"); } return t; } throw context.wrongTokenException( parser, JsonToken.VALUE_STRING, "Expected string for TimeZone after numeric values"); }
public T deserialize( JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) throws IOException { Object localObject; String str; if ((paramJsonParser.getCurrentToken() == JsonToken.START_ARRAY) && (paramDeserializationContext.isEnabled( DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS))) { paramJsonParser.nextToken(); localObject = deserialize(paramJsonParser, paramDeserializationContext); if (paramJsonParser.nextToken() != JsonToken.END_ARRAY) { throw paramDeserializationContext.wrongTokenException( paramJsonParser, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + this._valueClass.getName() + "' value but there was more than a single value in the array"); } } else { localObject = paramJsonParser.getValueAsString(); if (localObject == null) { break label194; } if (((String) localObject).length() != 0) { str = ((String) localObject).trim(); if (str.length() != 0) { break label118; } } localObject = _deserializeFromEmptyString(); } return (T) localObject; label118: paramJsonParser = null; try { localObject = _deserialize(str, paramDeserializationContext); if (localObject != null) { return (T) localObject; } } catch (IllegalArgumentException paramJsonParser) { localObject = "not a valid textual representation"; if (paramJsonParser != null) { localObject = "not a valid textual representation" + "problem: " + paramJsonParser.getMessage(); } paramDeserializationContext = paramDeserializationContext.weirdStringException( str, this._valueClass, (String) localObject); if (paramJsonParser != null) { paramDeserializationContext.initCause(paramJsonParser); } throw paramDeserializationContext; } label194: if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_EMBEDDED_OBJECT) { paramJsonParser = paramJsonParser.getEmbeddedObject(); if (paramJsonParser == null) { return null; } if (this._valueClass.isAssignableFrom(paramJsonParser.getClass())) { return paramJsonParser; } return (T) _deserializeEmbedded(paramJsonParser, paramDeserializationContext); } throw paramDeserializationContext.mappingException(this._valueClass); }