Forum Discussion

KTsnap's avatar
KTsnap
New Contributor III
4 years ago

Combining all records in one single JSON

Hi Team,
I have below input

[
  {
    "parents": "A",
    "value": "1"
  },
  {
    "parents": "B",
    "value": "2"
  },
  {
    "parents": "C",
    "value": "3"
  },
  {
    "parents": "D",
    "value": "4"
  }
]

When i tried using the expression :
{}.extend({“controllingFieldValue”:[$parents],“valueName”:$value})

I got the below Output

[
  {
    "controllingFieldValue": [
      "A"
    ],
    "valueName": "1"
  },
  {
    "controllingFieldValue": [
      "B"
    ],
    "valueName": "2"
  },
  {
    "controllingFieldValue": [
      "C"
    ],
    "valueName": "3"
  },
  {
    "controllingFieldValue": [
      "D"
    ],
    "valueName": "4"
  }
]

But i am expecting the above output to be in one JSON.Can experts please guide.