There is a JSON string, where we have engagedPartners array:
{
"sbData": [],
"listing": [
{
"db": {
"name": "abcd"
}
}
],
"audienceStats": {
"audienceStatus": 0
},
"userStats": {
"audienceName": "testWithNoCategory-1",
"audienceStatus": 1,
"engagedpartners": [
{
"name": "partner samWebsite 19999",
"viewsCount": 165,
"areaPage": 0,
"areaPageDescription": "xyz"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 336,
"areaPage": 1,
"areaPageDescription": "Promotions"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"areaPage": 2,
"areaPageDescription": "Vehicle Details"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"areaPage": 3,
"areaPageDescription": "Search Results"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"areaPage": 4,
"areaPageDescription": "About Us"
}
]
}
}
Inside it we need to update the key "areaPage" to "productPage" through this inner array using postgres, and the expected output should be shown below:
{
"sbData": [],
"listing": [
{
"db": {
"name": "abcd"
}
}
],
"audienceStats": {
"audienceStatus": 0
},
"userStats": {
"audienceName": "testWithNoCategory-1",
"audienceStatus": 1,
"engagedpartners": [
{
"name": "partner samWebsite 19999",
"viewsCount": 165,
"productPage": 0,
"productPageDescription": "xyz"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 336,
"productPage": 1,
"productPageDescription": "Promotions"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"productPage": 2,
"productPageDescription": "Vehicle Details"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"productPage": 3,
"productPageDescription": "Search Results"
},
{
"name": "partner samWebsite 19999",
"viewsCount": 1,
"productPage": 4,
"productPageDescription": "About Us"
}
]
}
}
I tried various options to reach out to this inner array and then update it but couldn't yet work.