hey everyone,
please excuse my beginners issues but I am having some really hard time accessing
items in nested json. At the moment I am trying to simply get the
- title
- url (found in source)
- main_name (found in actors)
- aliases (also found in actors)
from json that looks like this
{
"id": "123456789",
"title": "brad pitt on the rise",
"authors": "brian j. robb",
"language": "EN",
"sources": [{
"id": "123456789",
"name": "imdb",
"url": "https://www.imdb.com/name/nm0000093/",
"description": "brad pitt reference",
"reports": null
}],
"references": [
"https://www.imdb.com/name/nm0000093/"
],
"report_names": [
"brad pitt on the rise"
],
"actors": [{
"id": "123456789",
"main_name": "brad pitt",
"aliases": ["tyler durden", "Gummyhos"],
"source_name": "tv:shows",
"books": [
"The Rise to Stardom",
"The legendary Brad Pitt"
],
"source_id": "amazon",
"reports": null
}]
}
I tried the following in a transformer without much luck
const data = {{query.data.data}}
let final_data = [];
Object.keys(data).forEach(key => {
let new_obj = {}
new_obj.reports = data[key]
final_data.push(new_obj)
})
return final_data
any help is much appreciated!
Thank you!