Search code examples
symfonyjmsserializerbundlejms-serializer

Deserialize array of object using jms/serializer


I want to deserialize something like this:

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

Any idea how to do this?


Solution

  • It would be

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

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