Hi, I'm a newbie looking for help...
I have the following JSON:
{
"responseData": {
"feed": {
"author": "Music Store",
"type": "JSON",
"entries": [
{
"title": "1. Hello - Adele",
"link": "",
"author": "",
"publishedDate": "Mon, 15 Aug 2016 07:44:05 -0700",
"categories": [
"Music"
]
},
{
"title": "2. CHEAP THRILLS - SIA",
"author": "",
"categories": [
"Music"
]
},
{
"title": "3. LOVE YOURSELF - JUSTIN BIEBER",
"link": "",
"author": "",
"publishedDate": "Mon, 15 Aug 2016 07:44:05 -0700",
"categories": [
"Music"
]
},
{
"title": "4. Pokemon Theme - Pokémon",
"link": "",
"author": "",
"publishedDate": "Mon, 15 Aug 2016 07:44:05 -0700",
"categories": [
"Music"
]
},
{
"title": "5. STITCHES - SHAWN MENDES",
"link": "",
"author": "",
"publishedDate": "Mon, 15 Aug 2016 07:44:05 -0700",
"categories": [
"Music"
]
}
]
}
},
"responseDetails": null,
"responseStatus": 200
}
I'm trying to parse all the "title" elements as one single level array concatenated with another attribute -
which is the artist page on Wikipedia. the concatenation consist of :
Wikipedia URL ("https://en.wikipedia.org/wiki/) + the Artist name (e.g. Adele) = "https://en.wikipedia.org/wiki/Adele"
So, the new JSON should look like that:
{
"responseData": {
"feed": {
"author": "Music Store",
"type": "JSON",
"entries": [
{
"title": "1. Hello - Adele",
"wikipedia_url": "https://en.wikipedia.org/wiki/Adele",
"title": "2. U2 - War",
"wikipedia_url": "https://en.wikipedia.org/wiki/u2",
"title": "3. LOVE YOURSELF - Justin Bieber",
"wikipedia_url": "https://en.wikipedia.org/wiki/Justin_Bieber",
"title": "4. Pokemon Theme - Pokémon",
"wikipedia_url": "https://en.wikipedia.org/wiki/Pokémon",
"title": "5. STITCHES - Shawn Mendes",
"wikipedia_url": "https://en.wikipedia.org/wiki/Shawn_Mendes",
"categories": [
"Music"
]
}
]
}
},
"responseDetails": null,
"responseStatus": 200
}
I wrote the following function node, but it does not seem to work....
var data = JSON.parse(msg.payload);
var arr = data.responseData.feed.entries;
var msgs = [];
for (var i = 0; i< msg.payload.length; i++) {
msgs.push({payload: arr.title[i]});
}
return [msgs];
Any help would be much appreciated! 10x