I have a PHP multidimensional array which looks like this:
Array
(
[EUR] => Array
(
[title] => Euro
[symbol_left] =>
[symbol_right] => €
[decimal_point] => .
[thousand_point] => ,
[decimal_places] => 2
[currency_value] => 1.32306004
)
[USD] => Array
(
[title] => United States Dollars
[symbol_left] => $
[symbol_right] =>
[decimal_point] => .
[thousand_point] => ,
[decimal_places] => 2
[currency_value] => 1.00000000
)
)
when I encode it using PHP's json_encode() it looks like this:
{"EUR":{"title":"Euro","symbol_left":"","symbol_right":" €","decimal_point":".","thousand_point":",","decimal_places":"2","currency_value":"1.32306004"},"USD":{"title":"United States Dollars","symbol_left":"$","symbol_right":"","decimal_point":".","thousand_point":",","decimal_places":"2","currency_value":"1.00000000"}}
I have tried some of the standard ways to iterate through this is jQuery such as the following two:
for(item in json_currencies) {
var cash = json_currencies[item];
alert(cash.currency_value);
}
$.each(json_currencies, function(i,obj) {
alert(obj.currency_value);
});
The problem with both of these is that they will alert the two 'currency_value' items three times each, instead of just once.
What is the correct way to iterate through this jSON?