Refine search
@Override public TypeDeserializer forProperty(BeanProperty prop) { return (prop == _property) ? this : new AsPropertyTypeDeserializer(this, prop); }
if (p.canReadTypeId()) { Object typeId = p.getTypeId(); if (typeId != null) { return _deserializeWithNativeTypeId(p, ctxt, typeId); JsonToken t = p.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = p.nextToken(); return _deserializeTypedUsingDefaultImpl(p, ctxt, null); p.nextToken(); // to point to the value if (name.equals(_typePropertyName)) { // gotcha! return _deserializeTypedForId(p, ctxt, tb); tb = new TokenBuffer(p, ctxt); tb.writeFieldName(name); tb.copyCurrentStructure(p); return _deserializeTypedUsingDefaultImpl(p, ctxt, tb);
JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (deser == null) { if (p.isExpectedStartArrayToken()) { return super.deserializeTypedFromAny(p, ctxt); if (p.hasToken(JsonToken.VALUE_STRING)) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = p.getText().trim(); if (str.isEmpty()) { return null; msg = String.format("%s (for POJO property '%s')", msg, _property.getName()); JavaType t = _handleMissingTypeId(ctxt, msg); if (t == null) { tb.writeEndObject(); p = tb.asParser(p); p.nextToken(); return deser.deserialize(p, ctxt);
@SuppressWarnings("resource") protected Object _deserializeTypedForId(JsonParser p, DeserializationContext ctxt, TokenBuffer tb) throws IOException { String typeId = p.getText(); JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); if (_typeIdVisible) { // need to merge id back in JSON input? if (tb == null) { tb = new TokenBuffer(p, ctxt); } tb.writeFieldName(p.getCurrentName()); tb.writeString(typeId); } if (tb != null) { // need to put back skipped properties? // 02-Jul-2016, tatu: Depending on for JsonParserSequence is initialized it may // try to access current token; ensure there isn't one p.clearCurrentToken(); p = JsonParserSequence.createFlattened(false, tb.asParser(p), p); } // Must point to the next value; tb had no current, jp pointed to VALUE_STRING: p.nextToken(); // to skip past String value // deserializer should take care of closing END_OBJECT as well return deser.deserialize(p, ctxt); }
protected Object _deserializeTypedUsingDefaultImpl(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException, JsonProcessingException { // As per [JACKSON-614], may have default implementation to use if (_defaultImpl != null) { JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (tb != null) { tb.writeEndObject(); jp = tb.asParser(jp); // must move to point to the first token: jp.nextToken(); } return deser.deserialize(jp, ctxt); } // or, perhaps we just bumped into a "natural" value (boolean/int/double/String)? Object result = _deserializeIfNatural(jp, ctxt); if (result != null) { return result; } // or, something for which "as-property" won't work, changed into "wrapper-array" type: if (jp.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromAny(jp, ctxt); } throw ctxt.wrongTokenException(jp, JsonToken.FIELD_NAME, "missing property '"+_typePropertyName+"' that is to contain type id (for class "+baseTypeName()+")"); }
JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } else if (t == JsonToken.START_ARRAY) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); } else if (t != JsonToken.FIELD_NAME) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) { String name = jp.getCurrentName(); jp.nextToken(); // to point to the value if (_typePropertyName.equals(name)) { // gotcha! return _deserializeTypedForId(jp, ctxt, tb); tb = new TokenBuffer(null); tb.writeFieldName(name); tb.copyCurrentStructure(jp); return _deserializeTypedUsingDefaultImpl(jp, ctxt, tb);
@Override public Object deserializeTypedFromAny(JsonParser p, DeserializationContext ctxt) throws IOException { /* Sometimes, however, we get an array wrapper; specifically * when an array or list has been serialized with type information. */ if (p.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromArray(p, ctxt); } return deserializeTypedFromObject(p, ctxt); }
@SuppressWarnings("resource") protected final Object _deserializeTypedForId(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException { String typeId = jp.getText(); JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); if (_typeIdVisible) { // need to merge id back in JSON input? if (tb == null) { tb = new TokenBuffer(null, false); } tb.writeFieldName(jp.getCurrentName()); tb.writeString(typeId); } if (tb != null) { // need to put back skipped properties? jp = JsonParserSequence.createFlattened(tb.asParser(jp), jp); } // Must point to the next value; tb had no current, jp pointed to VALUE_STRING: jp.nextToken(); // to skip past String value // deserializer should take care of closing END_OBJECT as well return deser.deserialize(jp, ctxt); }
protected Object _deserializeTypedUsingDefaultImpl(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException, JsonProcessingException { // As per [JACKSON-614], may have default implementation to use if (_defaultImpl != null) { JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (tb != null) { tb.writeEndObject(); jp = tb.asParser(jp); // must move to point to the first token: jp.nextToken(); } return deser.deserialize(jp, ctxt); } // or, perhaps we just bumped into a "natural" value (boolean/int/double/String)? Object result = _deserializeIfNatural(jp, ctxt); if (result != null) { return result; } // or, something for which "as-property" won't work, changed into "wrapper-array" type: if (jp.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromAny(jp, ctxt); } throw ctxt.wrongTokenException(jp, JsonToken.FIELD_NAME, "missing property '"+_typePropertyName+"' that is to contain type id (for class "+baseTypeName()+")"); }
JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } else if (t == JsonToken.START_ARRAY) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); } else if (t != JsonToken.FIELD_NAME) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) { String name = jp.getCurrentName(); jp.nextToken(); // to point to the value if (_typePropertyName.equals(name)) { // gotcha! return _deserializeTypedForId(jp, ctxt, tb); tb = new TokenBuffer(null); tb.writeFieldName(name); tb.copyCurrentStructure(jp); return _deserializeTypedUsingDefaultImpl(jp, ctxt, tb);
@Override public Object deserializeTypedFromAny(JsonParser p, DeserializationContext ctxt) throws IOException { /* Sometimes, however, we get an array wrapper; specifically * when an array or list has been serialized with type information. */ if (p.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromArray(p, ctxt); } return deserializeTypedFromObject(p, ctxt); }
@SuppressWarnings("resource") protected final Object _deserializeTypedForId(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException { String typeId = jp.getText(); JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); if (_typeIdVisible) { // need to merge id back in JSON input? if (tb == null) { tb = new TokenBuffer(null, false); } tb.writeFieldName(jp.getCurrentName()); tb.writeString(typeId); } if (tb != null) { // need to put back skipped properties? jp = JsonParserSequence.createFlattened(tb.asParser(jp), jp); } // Must point to the next value; tb had no current, jp pointed to VALUE_STRING: jp.nextToken(); // to skip past String value // deserializer should take care of closing END_OBJECT as well return deser.deserialize(jp, ctxt); }
if (jp.canReadTypeId()) { Object typeId = jp.getTypeId(); if (typeId != null) { return _deserializeWithNativeTypeId(jp, ctxt, typeId); JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); } else if (t != JsonToken.FIELD_NAME) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); jp.nextToken(); // to point to the value if (_typePropertyName.equals(name)) { // gotcha! return _deserializeTypedForId(jp, ctxt, tb); tb = new TokenBuffer(null, false); tb.writeFieldName(name); tb.copyCurrentStructure(jp); return _deserializeTypedUsingDefaultImpl(jp, ctxt, tb);
JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (deser != null) { if (tb != null) { tb.writeEndObject(); p = tb.asParser(p); p.nextToken(); return deser.deserialize(p, ctxt); if (p.isExpectedStartArrayToken()) { return super.deserializeTypedFromAny(p, ctxt); if (p.hasToken(JsonToken.VALUE_STRING)) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = p.getText().trim(); "missing property '"+_typePropertyName+"' that is to contain type id (for class "+baseTypeName()+")"); return null;
@SuppressWarnings("resource") protected Object _deserializeTypedUsingDefaultImpl(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException { // As per [JACKSON-614], may have default implementation to use JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (deser != null) { if (tb != null) { tb.writeEndObject(); jp = tb.asParser(jp); // must move to point to the first token: jp.nextToken(); } return deser.deserialize(jp, ctxt); } // or, perhaps we just bumped into a "natural" value (boolean/int/double/String)? Object result = TypeDeserializer.deserializeIfNatural(jp, ctxt, _baseType); if (result != null) { return result; } // or, something for which "as-property" won't work, changed into "wrapper-array" type: if (jp.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromAny(jp, ctxt); } throw ctxt.wrongTokenException(jp, JsonToken.FIELD_NAME, "missing property '"+_typePropertyName+"' that is to contain type id (for class "+baseTypeName()+")"); }
@Override public Object deserializeTypedFromAny(JsonParser jp, DeserializationContext ctxt) throws IOException { /* [JACKSON-387]: Sometimes, however, we get an array wrapper; specifically * when an array or list has been serialized with type information. */ if (jp.getCurrentToken() == JsonToken.START_ARRAY) { return super.deserializeTypedFromArray(jp, ctxt); } return deserializeTypedFromObject(jp, ctxt); }
public InternalTypeDeserializer(Class<T> baseClass, TypeIdResolver typeIdResolver) { super(baseClass); this.typeDeserializer = new AsPropertyTypeDeserializer( TypeFactory.defaultInstance().constructType(baseClass), typeIdResolver, TYPE_PROPERTY, false, null); }
protected final Object _deserializeTypedForId(JsonParser jp, DeserializationContext ctxt, TokenBuffer tb) throws IOException, JsonProcessingException { String typeId = jp.getText(); JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); if (_typeIdVisible) { // need to merge id back in JSON input? if (tb == null) { tb = new TokenBuffer(null); } tb.writeFieldName(jp.getCurrentName()); tb.writeString(typeId); } if (tb != null) { // need to put back skipped properties? jp = JsonParserSequence.createFlattened(tb.asParser(jp), jp); } // Must point to the next value; tb had no current, jp pointed to VALUE_STRING: jp.nextToken(); // to skip past String value // deserializer should take care of closing END_OBJECT as well return deser.deserialize(jp, ctxt); }
if (jp.canReadTypeId()) { Object typeId = jp.getTypeId(); if (typeId != null) { return _deserializeWithNativeTypeId(jp, ctxt, typeId); JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); } else if (t != JsonToken.FIELD_NAME) { return _deserializeTypedUsingDefaultImpl(jp, ctxt, null); jp.nextToken(); // to point to the value if (_typePropertyName.equals(name)) { // gotcha! return _deserializeTypedForId(jp, ctxt, tb); tb = new TokenBuffer(null, false); tb.writeFieldName(name); tb.copyCurrentStructure(jp); return _deserializeTypedUsingDefaultImpl(jp, ctxt, tb);
JsonDeserializer<Object> deser = _findDefaultImplDeserializer(ctxt); if (deser == null) { if (p.isExpectedStartArrayToken()) { return super.deserializeTypedFromAny(p, ctxt); if (p.hasToken(JsonToken.VALUE_STRING)) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = p.getText().trim(); if (str.isEmpty()) { return null; msg = String.format("%s (for POJO property '%s')", msg, _property.getName()); JavaType t = _handleMissingTypeId(ctxt, msg); if (t == null) { tb.writeEndObject(); p = tb.asParser(p); p.nextToken(); return deser.deserialize(p, ctxt);