Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deserialize array of object using jms/serializer

I want to deserialize something like this:

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

Any idea how to do this?

like image 688
mykiwi Avatar asked Jun 11 '17 08:06

mykiwi


1 Answers

It would be

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

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

like image 94
zerkms Avatar answered Sep 18 '22 15:09

zerkms