This question already has an answer here:
I'm trying to get a JSON object's value like that:
obj = {"name": "abdou", "age": 23}
I know I can access to the value "abdou" by obj.name but assuming that I have a variable that hold the "name" like that:
key = "name"
So my question is how can I access to "abdou" using the variable key I tried
obj.key
but I think it's looking for a "key" value in the JSON object and replied with undefined.
Thank you.
via stodi
No comments:
Post a Comment