After trying some code to flatten a JSON, I found that it flattened the entire object. However, my specific requirement is to only flatten the position property.
Here is the JSON array I am working with:
[{
amount:"1 teine med 110 mtr iletau"
comment:""
created:"Tue May 17 2016 00:00:00 (W. Europe Standard Time)"
locationDescription:"På vestsiden av Jeløya, utenfor Moss. (Oslofjorden)."
position:{lat: 59.441388, lng: 10.579491}
time:"15-05-2016"
type:"Teine"
userId:""
},
{
amount:"1 teine med 110 mtr iletau"
comment:""
created:"Tue May 17 2016 00:00:00 (W. Europe Standard Time)"
locationDescription:"På vestsiden av Jeløya, utenfor Moss. (Oslofjorden)."
position:{lat: 59.441388, lng: 10.579491}
time:"15-05-2016"
type:"Teine"
userId:""
}]
I am looking for an output in the following format:
[{
amount:"1 teine med 110 mtr iletau"
comment:""
created:"Tue May 17 2016 00:00:00 (W. Europe Standard Time)"
locationDescription:"På vestsiden av Jeløya, utenfor Moss. (Oslofjorden)."
position.lat:59.441388,
position.lng: 10.579491,
time:"15-05-2016"
type:"Teine"
userId:""
},
{
amount:"1 teine med 110 mtr iletau"
comment:""
created:"Tue May 17 2016 00:00:00 (W. Europe Standard Time)"
locationDescription:"På vestsiden av Jeløya, utenfor Moss. (Oslofjorden)."
position.lat: 59.441388,
position.lng: 10.579491,
time:"15-05-2016"
type:"Teine"
userId:""
}]
If anyone can provide suggestions on how to achieve this desired output using JavaScript, I would greatly appreciate it.