Skip to content

ArrayListMultimapDeserializer does not support multimaps inside another object as a property #104

Closed
@magical-l

Description

@magical-l

CN: (guava module) ArrayListMultimapDeserializer 未支持multimap作为其他对象的属性。
EN: (guava module) ArrayListMultimapDeserializer does not support multimaps inside another object as a property

CN: 在 com.fasterxml.jackson.datatype.guava.deser.multimap.GuavaMultimapDeserializer:209 行(deserializeFromSingleValue(JsonParser p, DeserializationContext ctxt) 方法中),我们将会检查p.getCurrentToken()是否为JsonToken.START_OBJECT
EN: at com.fasterxml.jackson.datatype.guava.deser.multimap.GuavaMultimapDeserializer:209 (inside the method deserializeFromSingleValue(JsonParser p, DeserializationContext ctxt) ), we will check whether the value of p.getCurrentToken() is JsonToken.START_OBJECT.

若multimap作为json的整体,此时p.getCurrentToken()确实是JsonToken.START_OBJECT。
if we are deserialize the whole json object to a multimap, then p.getCurrentToken() is exactly JsonToken.START_OBJECT.

但若multimap作为另一个对象的属性,如下:
but what if the multimap is a property of another object:

{
    'theMultimapProperty':{
        '@class':'com.google.common.collect.ArrayListMultimap',//or com.google.common.collect.Multimaps$CustomListMultimap ...
        'a': [1,2]
    }
}

此时p.getCurrentToken()将是JsonToken.FIELD_NAME,对应其作为另一对象属性的属性名theMultimapProperty
then now the value of p.getCurrentToken() would be JsonToken.FIELD_NAME , as the property name for the multimap in the outside object theMultimapProperty.

然后解析失败。
and then the deserialization fails.

jackson version: 2.13.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions