Thor
Honorary Master
- Joined
- Jun 5, 2014
- Messages
- 44,236
Now on to the next phase!
I would like to create a chart using data I have access to via a JSON API or not sure what the term here is the API spits out the data in JSON if that makes more sense.
I would like to use a specific Charting library, but they use the data is this form:
I have my data in this form (This is how I get it from the API I have access to.)
So now my question is, is it possible to "convert" my data into the format the charting library would like?
I was thinking of using a for loop and string replace with/in php, but that is just my noob thinking so I guess my question is; How do I convert JSON data from one format to another?
I would like to create a chart using data I have access to via a JSON API or not sure what the term here is the API spits out the data in JSON if that makes more sense.
I would like to use a specific Charting library, but they use the data is this form:
Code:
?([
[Date.UTC(2013,5,2),0.7695],
[Date.UTC(2013,5,3),0.7648],
[Date.UTC(2013,5,4),0.7645],
[Date.UTC(2013,5,5),0.7638],
[Date.UTC(2013,5,6),0.7549],
[Date.UTC(2013,5,7),0.7562],
[Date.UTC(2013,5,9),0.7574],
[Date.UTC(2013,5,10),0.7543],
[Date.UTC(2013,5,11),0.7510],
[Date.UTC(2013,5,12),0.7498],
[Date.UTC(2013,5,13),0.7477],
[Date.UTC(2013,5,14),0.7492],
[Date.UTC(2013,5,16),0.7487],
[Date.UTC(2013,5,17),0.7480],
[Date.UTC(2013,5,18),0.7466]
]);
I have my data in this form (This is how I get it from the API I have access to.)
Code:
"price": [
{
"dateTime": "2016-08-10T21:00:00Z",
"value": 13.2946
},
{
"dateTime": "2016-08-10T21:05:00Z",
"value": 13.2947
},
{
"dateTime": "2016-08-10T21:10:00Z",
"value": 13.2959
},
{
"dateTime": "2016-08-10T21:15:00Z",
"value": 13.2989
},
{
"dateTime": "2016-08-10T23:00:00Z",
"value": 13.3006
}
],
So now my question is, is it possible to "convert" my data into the format the charting library would like?
I was thinking of using a for loop and string replace with/in php, but that is just my noob thinking so I guess my question is; How do I convert JSON data from one format to another?