0

I've used the json_decode function to convert the given json into an object, I can then address each of these by using something like $givenobject->name or $givenobject->productdetails->name. the problem is, instead of using a simple index for a key, the table I am trying to decode from has used an integer for the key that's being treated as a string. I cant do $givenobject->productdetails->"1"->name since that would just throw an error.

Heres an example of the given json:

{
  "id":"1",
  "info":{
    "1":{
      "name":"Example",
      "description":"Example description"
    }
  }
}

How would I extract the "name" variable from this table without having to go:

$tabledata->info->1->name

Toaster
  • 16
  • 3

0 Answers0