mercredi 19 octobre 2016

prevent json encode from returning arrays as strings

I get the following json response when I query my database:

[{"id":1,"name":"my name","street":"Sava Burica","city":"Belgrade","state":"Zemun","zip":"11080","country":"Serbia","giftwrap":null,"products":"[{\"count\":2,\"id\":1,\"price\":275,\"name\":\"Kayak\"},{\"count\":1,\"id\":2,\"price\":48.95,\"name\":\"Lifejacket\"}]"}]

It is all good except that the products value is a string and it should be an array.

I am using Laravel 5.3 as my framework but I don't think that makes a difference.

Can I somehow force it to return arrays as arrays and not as strings?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire