0

I have an API response that is returning in this format:

inventory({
"count": 40, 
"vehicles": [{
"VehicleInfoId": 989889, 
"StockNumber": 787878, 
"make": "ram"
 }]
});

I have tried:

$final = json_encode($response, true);

To try and parse the output with no luck. Any idea of how to approach parsing this response?

Thanks in advance.

Alexis Philip
  • 517
  • 2
  • 5
  • 23
dc_0515
  • 13
  • 5
  • Well it would be json_decode, but that's only partly JSON. – AbraCadaver Jan 14 '20 at 18:39
  • That's not valid JSON. JSON requires quotes around object keys. You also can't have a function call around it. It looks more like JSONP. – Barmar Jan 14 '20 at 18:42
  • @mario The solutions there won't work if the argument isn't valid JSON. They just remove the function call and use `json_decode()`. – Barmar Jan 14 '20 at 18:44
  • @Barmar Oh, right, the inner part is also JSOL. Gonna add another dupe... / just in case – mario Jan 14 '20 at 18:46
  • @mario thanks that first "Extract JSONP Resultset in PHP" question/answer helped – dc_0515 Jan 15 '20 at 22:52

0 Answers0