I have the below object
{
lookUp: {
id: "123",
text: {
street_address_test: [
{
pos: 12,
len: 6,
},
{
pos: 3,
len: 8,
},
{
pos: 3,
len: 15,
},
],
},
},
}
I want to append the below (using JavaScript i.e nodejs to be specific)
street_address_uk: [
{
pos: 12,
len: 6,
},
{
pos: 3,
len: 8,
},
{
pos: 3,
len: 15,
},
],
so that it becomes
{
lookUp: {
id: "123",
text: {
street_address_test: [
{
pos: 12,
len: 6,
},
{
pos: 3,
len: 8,
},
{
pos: 3,
len: 15,
},
],
street_address_uk: [
{
pos: 12,
len: 6,
},
{
pos: 3,
len: 8,
},
{
pos: 3,
len: 15,
},
],
},
},
}
I looked at existing Stack Overflow posts and https://stackoverflow.com/a/8889386/4068218 was close but dynamically I will not know street_address_test or street_address_uk.
I went through other Stack Overflow posts as well but most of the solutions were on arrays but as you see mine is not an array.
Any leads are much appreciated.
jsonObj["lookUp"]["text"]["street_address_uk"] = appendObj["street_address_uk"];?jsonObj["lookUp"]["text"]["street_address_uk"] =[{pos: 12,len: 6,},{pos: 3,len: 8,},{pos: 3, len: 15,},];if it's a constantjsonObj.lookUp.text.street_address_uk?