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
2 Answers 2
Since cc is a variable, you should remove the quotes ". Try:
console.log (main.listing[cc]);
answered Aug 21, 2018 at 0:08
f-CJ
4,5392 gold badges33 silver badges29 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
You can access the data using
Main.Listing[cc]
Comments
lang-js
main.listing[cc]