BackGround : I am trying to parse this simple json response in my SenchaTouch Application.
json response:
{
"Australia":
[
{
"Currency": "AustralianDollar",
}
],
"INDIA":
[
{
"Currency": "INR"
}
],
"USA":
[
{
"Currency": "USD"
}
]
}
I want to fetch country’s currency based on the Country name.
I am trying to fetch the currency value as below.
var country = text.Australia.name;
console.log('Country name is'+country);
but it gives me error. Can any one please explain on how to parse give country name as input and fetch the currency?
Thank you,
Gendaful
The simplest way to do it is:
Check out json.org for better/safer ways to do it.
Working example here.
Check out this compatibility chart for using
JSON.parse(text);.