Reputation: 81
To access specific JSON data i need to access Main -> Listing -> c44 -> Mydata
c44
is dynamic and can be anything.
I have it in my variable - var cc
To access needed data, i write:
var result = Main.listing. * how can i specify cc var here? *
Tried console.log (main.listing.["cc"]);
but never worked
Upvotes: 2
Views: 126
Reputation: 4481
Since cc
is a variable, you should remove the quotes "
. Try:
console.log (main.listing[cc]);
Upvotes: 4