I have Json output file in Kimonolabs lookin like this
{
"name": "text",
"results": {
"collection1": [
{
"title": {
"href": "link",
"text": "text"
},
"description": "text",
"author": "text",
"index": 1,
"url": "link"
},etc.
}]}}
I want to add a variable 'category' to the variables in the collection1 array, and make the value of that category 'food' for each of the array items. But struggling all day to get it working. Any suggestions?
What I tried is:
function transform (data){
//create shortcut for collection variable
var collection = data.results.collection1;
//function to add category
function addcat(line){
line[category] ='food';
return row;
}
//loop through variables;
for (var i=0; i < collection.length; i++){
[collection] = [collection].map(addcat);
return data;
}