0

i have this string type variable

$product = "[{'id':'1','variant_id':'86','qty':'2','note':'dont have any'},{'id':'2','variant_id':'2','qty':'2','note':'ok'}]";

from the payload i get from postman request, and i want to do the foreach loop to get the item i need

and when i tried to decode it like this

$product = json_decode($product,true);
return $product;

the result is empty / null, is there something wrong with my json string?

by the way here is the postman body

{
"key":"cart",
"method":"post",
"payload": "{\"user_id\":\"1\",\"store_id\":\"1\",\"note\":\"okeee\",\"uuid\":\"{{uuid}}\",\"product\":\"[{'id':'1','variant_id':'86','qty':'2','note':'dont have any'},{'id':'2','variant_id':'2','qty':'2','note':'ok'}]\"}"
}
ucup
  • 665
  • 6
  • 17

0 Answers0