json_encode is returning NULL?

前端 未结 10 1949
[愿得一人]
[愿得一人] 2020-11-22 12:22

For some reason the item \"description\" returns NULL with the following code:



        
10条回答
  •  春和景丽
    2020-11-22 12:44

    For me, an issue where json_encode would return null encoding of an entity was because my jsonSerialize implementation fetched entire objects for related entities; I solved the issue by making sure that I fetched the ID of the related/associated entity and called ->toArray() when there were more than one entity associated with the object to be json serialized. Note, I'm speaking about cases where one implements JsonSerializable on entities.

提交回复
热议问题