I have a json file array with data and I want to use it in a jquery array.
My json file is like this;
[{"id":"1","value":"0.00","score":"a"},
{"id":"2","value":"0.00","score":"c"},
{"id":"3","value":"12.56","score":"e"}]
and then my jquery array outcome i want should be like this (but missing the score and value data.
var setup = [
{
"type": "single",
"subtype": {
"type": "Point",
"score": use 'score' of the json file
},
"properties": {
"text": use 'value' of the json file,
"height": 60
}
},
{
"type": "single",
"subtype": {
"type": "Point",
"score": use score of the json file
},
"properties": {
"text": use value of the json file,
"height": 60
}
}
];
Below I made an attemp to set up a jquery array but i am mnot so good in this. I think i have to use a double $each? but how do I make the array?
var setup = [];
// FETCHING DATA FROM JSON FILE
$.getJSON("results.json", function(data) {
// ITERATING THROUGH OBJECTS
$.each(data, function (key, value) {
var test = "";
$.each(value, function(index, obj) {
});
});
setup.push(setup);
});
Thanks in advance :)