Skip to content

Type id not exposed for JsonTypeInfo.As.EXTERNAL_PROPERTY even when visible set to true #1288

@libetl

Description

@libetl

Jackson : 2.8.0.rc2

Hello,

I have these following jsons to deserialize, with a type property ("form_of_payment") located outside a polymorphic class ("payment_details") :

    {"form_of_payment":"INDIVIDUAL_CREDIT_CARD","payment_details":{"card_holder_first_name":"John", "card_holder_last_name":"Doe",  "number":"XXXXXXXXXXXXXXXX", "expiryDate":"MM/YY"}
    {"form_of_payment":"INSTRUMENTED_CREDIT_CARD","payment_details":{"payment_instrument_id":"00000000-0000-0000-0000-000000000000", "name":"Mr John Doe encrypted credit card"}

I have to use the @JsonTypeInfo annotation on the PaymentDetails class, to inform Jackson that there are several kinds of PaymentDetails.

The include must be a include = JsonTypeInfo.As.EXTERNAL_PROPERTY.

Once the TypeResolver has done his job, the JsonTypeInfo is removed from the feed, which annoys me a lot (the "form_of_payment" also must be read for business purposes). If it is an EXTERNAL_PROPERTY, there is no way to restore it (it works with PROPERTY, but the JsonTypeInfo must be inside the same object)

Can you add a spare visibility property to the @JsonTypeInfo to find it in the parent object ?
Here is a link to where it happens : https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java#L99

Thanks.

(I have seen the #408 issue BTW)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions