Forum Discussion
KTsnap
4 years agoNew Contributor III
Hi Bojan,
IN this way ,
[
"Value" : {
{
"controllingFieldValue": [
"A"
],
"valueName": "1"
},
{
"controllingFieldValue": [
"B"
],
"valueName": "2"
},
{
"controllingFieldValue": [
"C"
],
"valueName": "3"
},
{
"controllingFieldValue": [
"D"
],
"valueName": "4"
}
}
]
bojanvelevski
4 years agoValued Contributor
This is not a valid JSON. The value of the “Value” object can either be a string,number,boolean, array , or object with key value pairs, but not multiple object literals. You can group all of the documents in one array ($group) , and use the following expression:
$group.map(x=>{"controllingFieldValue":[x.parents],"valueName":x.value})
And map the target path as Value, than you’ll have all of the objects but in an array.
- KTsnap4 years agoNew Contributor III
This helped… Thank you 🙂