-1

I've a valid json of the following format.I want to be able to print the value of desc.

 var obj = 
    {
        "x-internal": {
            "name": {
                "desc": "abc"
            }
        }
    }

console.log(" Val :"+obj.x-hooks.warehouse.desc);

I get a reference error saying hooks is not defined.

bharz629
  • 161
  • 2
  • 4
  • 10

1 Answers1

-1

This should work:

 console.log(" Val :"+obj["x-hooks"].warehouse.desc);

For clarity, I'm assuming x-hooks is in part of obj

li0n_za
  • 455
  • 2
  • 15