-2

Please let me know how to convert json string to json object in php?

I have tried convert json string to json object in php not getting json array properly..

for example:

{"return":"{\"catinfo\":[{\"ID\":\"1\",\"NAME\":\"test1\"},{\"ID\":\"2\",\"NAME\":\"test2\"}]}"}

how to resolve it as like

{"catinfo":[{"ID":"1","NAME":"test1"},{"ID":"2","NAME":"test2"}]}"}
Naftali
  • 144,921
  • 39
  • 244
  • 303
rahul
  • 1
  • 3

1 Answers1

-1
$object = json_decode($string);

In your case you would like sth like this:

$catInfo = json_decode('{"return":"{\"catinfo\":[{\"ID\":\"1\",\"NAME\":\"test1\"},{\"ID\":\"2\",\"NAME\":\"test2\"}]}"}')->return;
jakub wrona
  • 2,212
  • 17
  • 17