How can I deserialize an array of objects in Symfony Serializer?

前端 未结 3 1272
心在旅途
心在旅途 2021-02-20 11:29

Is is possible in Symfony Serializer to deserialize an array of objects in a property? I have a Boss class with the $Npc = [] property tha

3条回答
  •  孤城傲影
    2021-02-20 11:52

    I have struggled with this many hours without getting a result. Every time i added an adder function, the objectnormalizer wanted to invoke this function but got an error something like "The field xyz should be of type xyz[], array given".

    This is cause i forgot to add the ArrayDenormalizer to the normalizer pool of the serializer. After adding this, everything worked fine.

    Hope this is helpful for somebody.

提交回复
热议问题