Looking to iterate through the object below and extract author names based on matching titles with other objects. The goal is to create a new object for easier management.
business1
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-89.535,
34.3654
]
},
"place_name": "University, Mississippi, United States",
"properties": {
"title": "Using Adversarial Autoencoders for Multi-Modal Automatic Playlist Continuation",
"authorTitle": "Florian Mai"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
10.14,
54.33
]
},
"place_name": "24105, Kiel, Schleswig-Holstein, Germany",
"properties": {
"title": "Using Adversarial Autoencoders for Multi-Modal Automatic Playlist Continuation",
"authorTitle": "Iacopo Vagliano"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
10.14,
54.33
]
},
"place_name": "pretend place",
"properties": {
"title": "new title",
"authorTitle": "joe blogs"
}
}
],
"properties": "",
"authors": ""
}
Desired Object (improvedObj)
var improvedObj = {
obj1 = {
title:'Using Adversarial Autoencoders for Multi-Modal Automatic Playlist Continuation"',
authorList: 'Florian Mai,Iacopo Vagliano'
},
obj2 = {
title:'new title',
authorList: 'joe blogs
}
}
Attempt at Solution
extractorArray = []
for(i=0; i<business1.features.length;i++){
extractorArray.push(business1.features[i].properties)
}
console.log('extractor', extractorArray)
var extractedValues = extractorArray.map((title) => (title));
var extractedAuthor = extractorArray.map((authorTitle) => (authorTitle))
var improvedObj = {
objList : {
title:extractedValues,
authorList: extractedAuthor
}
}
The code loops through each feature, extracts properties into the extractorArray
, and attempts to match titles for author extraction. However, this approach does not currently achieve the desired result of linking authors to matching titles.