Deserialize array of object using jms/serializer

mykiwi picture mykiwi · Jun 11, 2017 · Viewed 11.3k times · Source

I want to deserialize something like this:

[
    { "id": 42 },
    { "id": 43 }
]

Any idea how to do this?

Answer

zerkms picture zerkms · Jun 11, 2017

It would be

$serializer->deserialize($json, 'array<T>', 'json')

where T is the name of the class with the id property.