0

I am using Lumen + Dingo + Ember JS I am able to transform the response into JSON API. But when I post back the data from Ember, is it in same json api format. So I want to know is there any way to deform the json api data ?

data":{"attributes":{"size":2},"relationships":{"page":{"data":{"type":"pages","id":"2"}}},"type":"rows"}}

From above response, i want to get `size=2, pageId=2

I have properly used relationship in Lumen models.

Any idea, how can I achieve this?

P.s The question is about deformation of data from json api format, but not about json encode/decode.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Gev Balyan
  • 491
  • 1
  • 4
  • 9

1 Answers1

0

if you are trying to decode in javascript then

JSON.parse(jsonString) // where jsonString is your string this will return parsed object in javascript

if you are trying to decode in php then

json_decode(jsonString) // will give you stdClass object
Sagar Rabadiya
  • 4,126
  • 1
  • 21
  • 27
  • 1
    :Its not about json encode decode. The question is about deformation of data from json api format. – Gaurav Oct 21 '16 at 13:22
  • Yes, Gaurav is right. The question is about deformation of data from json api format. – Gev Balyan Oct 24 '16 at 05:26
  • if the above data is in string format than json_decode() in php will deform it to object or array whichever you want check here http://php.net/manual/en/function.json-decode.php – Sagar Rabadiya Oct 24 '16 at 05:41