Skip to content

Add support for implicit array serialization #38

@natenobility

Description

@natenobility

It should be possible to parse an array of objects even if the corresponding value in the dictionary is not an array. A use case is as follows: you parse xml that is designed to be an array but only has a single element. The xml parser has no knowledge of the array intention, and most will just parse this to a dictionary, not an array of one element. This library, however, can actually convert these properly with no additional configuration as it knows the target property is an array type. To clarify further with an example:

This json can be parsed into a user with an array of one tweet:

{
"name": "Diego Chohfi",
"tweets": [
{
"id_str": 190957570511478800,
"text": "Tweet text"
}
]
}

However, this too should be parseable as a user with an array of one tweet (provided you specify an array mapping for property "tweets" of course), but I don't see a way to do it currently:

{
"name": "Diego Chohfi",
"tweets":
{
"id_str": 190957570511478800,
"text": "Tweet text"
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions