Possible Duplicate:
Accessing nested JavaScript objects with string key
I am trying to parse a JSON object and retrieve the values from it. The JSON structure is as follows
"projects": {
"P116805": {
"id": "P116805",
"regionname": "AFRICA",
"lendinginstr": "Specific Investment Loan",
"project_name": "Capacity Building for Regional Coordination of Sustainable Forest Management in the Congo Basin under the GEF Program for the Congo",
"closingdate": "2013-06-30T00:00:00Z",
"lendprojectcost": "1,920,000",
"totalamt": "0",
"grantamt": "820,000",
"url": "http://www.worldbank.org/projects/P116805/capacity-building-regional-coordination-sustainable-forest-management-congo-basin-under-gef-program-congo?lang=en",
"countrycode": "3A",
"countryname": "Africa"
}
I am trying to get the value of 'regionname' within Projects/P116805. I get the key name to be parsed on runtime as projects.P116805.regionname. I store that in a variable and use that for parsing.
I am trying to parse the value as follows
var obj = JSON.parse(response);
var key = projects.P116805.regionname;
I can get these values as projects.P116805.regionname but in my case i am not able to do that.If i use obj.key, i am not getting the correct values. Can anyone help me resolve this issue.