Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deserialize JSON if property might have a list of subobjects? #355

Closed
jeserkin opened this issue Oct 16, 2014 · 5 comments
Closed

Comments

@jeserkin
Copy link
Contributor

How to deserialize JSON if property might have a list of subobjects? i.e.

"heroes": [{
        "paragonLevel": 100,
        "seasonal": false,
        "name": "DrEugene",
        "id": 8275384,
        "level": 70,
        "hardcore": false,
        "gender": 0,
        "dead": false,
        "class": "witch-doctor",
        "last-updated": 1413061455
    }, {
        "paragonLevel": 100,
        "seasonal": false,
        "name": "Eugene",
        "id": 7968486,
        "level": 70,
        "hardcore": false,
        "gender": 0,
        "dead": false,
        "class": "monk",
        "last-updated": 1413074335
    }, {
        "paragonLevel": 100,
        "seasonal": false,
        "name": "BowmanEugene",
        "id": 15457030,
        "level": 70,
        "hardcore": false,
        "gender": 0,
        "dead": false,
        "class": "demon-hunter",
        "last-updated": 1413233724
    }, {
        "paragonLevel": 100,
        "seasonal": false,
        "name": "FullFury",
        "id": 32192193,
        "level": 70,
        "hardcore": false,
        "gender": 0,
        "dead": false,
        "class": "barbarian",
        "last-updated": 1413046645
    }]

What would be the right mapping in this case? Do I need to use @XmlList annotation or it doesn't work with JSON?

@xabbuh
Copy link
Contributor

xabbuh commented Oct 17, 2014

In your metadata, you can configure a property to be an array of other objects (see the available types here).

@jeserkin
Copy link
Contributor Author

Okey. Will try that out. Thank you.

@jeserkin
Copy link
Contributor Author

@xabbuh any chance, there is a way to say something like @Type("T<T>") or @Type("T<key, T>"), since I've got my own ArrayCollection implementation and I would like to use it as an array implementation? I've seen, that I can use normal array and ArrayCollection from Doctrine.

@xabbuh
Copy link
Contributor

xabbuh commented Oct 18, 2014

@jeserkin Not that I'm aware of it.

@goetas
Copy link
Collaborator

goetas commented Mar 21, 2017

@goetas goetas closed this as completed Mar 21, 2017
@goetas goetas reopened this Mar 21, 2017
@goetas goetas closed this as completed Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants