This is a return from Currency Data API on APILayer
How can I convert this JSON to display exchange rate chart for USDJPY?
I am thinking I have to change the JSON structure by going through Obect.keys(quotes)
and recreate normalized 2d array with date and rate?
Not really familiar with JavaScript nor a datasience.
{
"success": true,
"timeframe": true,
"start_date": "2022-09-01",
"end_date": "2022-12-03",
"source": "USD",
"quotes": {
"2022-09-01": {
"USDAED": 3.673104,
"USDAFN": 87.999866,
"USDALL": 118.150031,
"USDAMD": 404.740098,
"USDANG": 1.802905,
"USDAOA": 428.58145,
"USDARS": 139.158405,
"USDAUD": 1.471627,
"USDAWG": 1.805,
"USDAZN": 1.705142,
"USDBAM": 1.952735,
"USDBBD": 2.019869,
"USDBDT": 95.062454,
"USDBGN": 1.966631,
"USDBHD": 0.37696,
"USDBIF": 2047,
"USDBMD": 1,
"USDBND": 1.400058,
"USDBOB": 6.912724,
"USDBRL": 5.241899,
"USDBSD": 1.000349,
"USDBTC": 0.000049694274,
"USDBTN": 79.489381,
"USDBWP": 12.891418,
"USDBYN": 2.525497,
"USDBYR": 19600,
"USDBZD": 2.016474,
"USDCAD": 1.31475,
"USDCDF": 2025.000146,
"USDCHF": 0.98134,
"USDCLF": 0.032511,
"USDCLP": 897.069434,
"USDCNY": 6.906985,
"USDCOP": 4480.5,
"USDCRC": 647.546303,
"USDCUC": 1,
"USDCUP": 26.5,
"USDCVE": 111.150308,
"USDCZK": 24.611013,
"USDDJF": 177.71988,
"USDDKK": 7.47304,
"USDDOP": 53.050592,
"USDDZD": 140.800539,
"USDEGP": 19.232695,
"USDERN": 15,
"USDETB": 52.410121,
"USDEUR": 1.004825,
"USDFJD": 2.22975,
"USDFKP": 0.823605,
"USDGBP": 0.86593,
"USDGEL": 2.870355,
"USDGGP": 0.823605,
"USDGHS": 10.050199,
"USDGIP": 0.823605,
"USDGMD": 55.150003,
"USDGNF": 8700.000124,
"USDGTQ": 7.742628,
"USDGYD": 209.295592,
"USDHKD": 7.84825,
"USDHNL": 24.54502,
"USDHRK": 7.552598,
"USDHTG": 118.039907,
"USDHUF": 403.950419,
"USDIDR": 14902.15,
"USDILS": 3.39782,
"USDIMP": 0.823605,
"USDINR": 79.71705,
"USDIQD": 1460,
"USDIRR": 42250.000275,
"USDISK": 142.17995,
"USDJEP": 0.823605,
"USDJMD": 150.886127,
"USDJOD": 0.708985,
"USDJPY": 140.081974,
"USDKES": 120.203969,
"USDKGS": 80.7825,
"USDKHR": 4114.999725,
"USDKMF": 494.950184,
"USDKPW": 900.00035,
"USDKRW": 1356.199039,
"USDKWD": 0.308403,
"USDKYD": 0.833608,
"USDKZT": 471.125045,
"USDLAK": 15487.49364,
"USDLBP": 1518.000512,
"USDLKR": 365.15671,
"USDLRD": 154.250239,
"USDLSL": 17.28737,
"USDLTL": 2.95274,
"USDLVL": 0.60489,
"USDLYD": 4.924996,
"USDMAD": 10.616495,
"USDMDL": 19.376588,
"USDMGA": 4124.99974,
"USDMKD": 61.930847,
"USDMMK": 2100.828432,
"USDMNT": 3194.961563,
"USDMOP": 8.086328,
"USDMRO": 356.999828,
"USDMUR": 44.548039,
"USDMVR": 15.349849,
"USDMWK": 1024.481055,
"USDMXN": 20.181901,
"USDMYR": 4.481012,
"USDMZN": 63.829513,
"USDNAD": 17.296201,
"USDNGN": 422.95952,
"USDNIO": 36.000119,
"USDNOK": 10.049975,
"USDNPR": 127.183409,
"USDNZD": 1.643615,
"USDOMR": 0.384998,
"USDPAB": 1.000349,
"USDPEN": 3.855498,
"USDPGK": 3.519536,
"USDPHP": 56.859697,
"USDPKR": 218.150148,
"USDPLN": 4.739185,
"USDPYG": 6895.112576,
"USDQAR": 3.641001,
"USDRON": 4.862202,
"USDRSD": 117.875015,
"USDRUB": 60.209653,
"USDRWF": 1036.5,
"USDSAR": 3.757609,
"USDSBD": 8.210319,
"USDSCR": 13.04492,
"USDSDG": 577.499323,
"USDSEK": 10.793045,
"USDSGD": 1.401619,
"USDSHP": 1.377406,
"USDSLL": 14174.999857,
"USDSOS": 568.499662,
"USDSRD": 25.264956,
"USDSTD": 20697.981008,
"USDSVC": 8.753432,
"USDSYP": 2512.53037,
"USDSZL": 17.307067,
"USDTHB": 36.781031,
"USDTJS": 10.15366,
"USDTMT": 3.5,
"USDTND": 3.220336,
"USDTOP": 2.357796,
"USDTRY": 18.212099,
"USDTTD": 6.781688,
"USDTWD": 30.563199,
"USDTZS": 2331.999802,
"USDUAH": 36.944044,
"USDUGX": 3806.476092,
"USDUYU": 40.810743,
"USDUZS": 10975.00004,
"USDVND": 23462.5,
"USDVUV": 116.056079,
"USDWST": 2.66746,
"USDXAF": 654.954919,
"USDXAG": 0.056065,
"USDXAU": 0.000589,
"USDXCD": 2.70255,
"USDXDR": 0.768824,
"USDXOF": 655.499588,
"USDXPF": 120.375032,
"USDYER": 250.25001,
"USDZAR": 17.26735,
"USDZMK": 9001.198478,
"USDZMW": 15.306082,
"USDZWL": 321.999592
},
"2022-09-02": {
"USDAED": 3.673005,
"USDAFN": 89.000368,
"USDALL": 118.000368,
"USDAMD": 404.590403,
"USDANG": 1.802629,
"USDAOA": 428.55865,
"USDARS": 139.148868,
"USDAUD": 1.468213,
"USDAWG": 1.8,
"USDAZN": 1.70397,
"USDBAM": 1.95673,
"USDBBD": 2.019529,...
I normalized the data with below code
const source = {{ USDrateHistory.data.quotes }}
var normalized = Object.keys(source).map(date =>{
var rate = source[date].USDJPY
var obj = {
"date" : date,
"Rate" : rate
}
return obj
})
return normalized
and set the results in source and it ended up like this.