I am working with a JSON data object that includes exchange rates information:
{
"disclaimer": "Exchange rates provided for informational purposes only and do not constitute financial advice of any kind. Although every attempt is made to ensure quality, no guarantees are made of accuracy, validity, availability, or fitness for any purpose. All usage subject to acceptance of Terms: https://openexchangerates.org/terms/",
"license": "Data sourced from various providers; resale prohibited; no warranties given of any kind. All usage subject to License Agreement: https://openexchangerates.org/license/",
"timestamp": 1475110853,
"base": "USD",
"rates": {
"AED": 3.672983,
"AFN": 66.5538,
"ALL": 122.0421,
"AMD": 473.5925,
"ANG": 1.7763,
"AOA": 165.571834,
"ARS": 15.3169,
"AUD": 1.299338,
"AWG": 1.792667,
"YER": 250.130999,
"ZAR": 13.61321,
"ZMK": 5252.024745,
"ZMW": 9.831204,
"ZWL": 322.387247
}
}
Additionally, I have defined my model structure as shown below:
Ext.define('CurrencyConvert.model.CurrencyCode', {
extend : 'Ext.data.Model',
fields : [
{
name : 'code',
value : 'string'
},
{
name : 'rate',
value : 'float'
}
]
});
The challenge I am facing is that the currency code is also the property name for the actual rate. How can I set up my store in a way that allows me to retrieve both the code and the rate values for each currency?
For example, for "AED": 3.672983
, I would like the code
field to contain "AED" and the rate
field to hold 3.672983.