cancel
Showing results for 
Search instead for 
Did you mean: 

Insert a new dynamic record in JSON under array field

KTsnap
New Contributor III
Hi Everybody,
Kindly help.
Am trying to insert a dynamic value under the **value** array using extend function but unable to do so. 
[
{
"entity":
{
"attributes":
{
"type":"CustomField","url":"A"
}
"Metadata":
{
"valueSet":
{
"value":
[
{
"color":null,"default":false,"description":null,"isActive":null,"label":"None","urls":null,"valueName":"None"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Country","urls":null,"valueName":"Country"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Employee","urls":null,"valueName":"Employee"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Both","urls":null,"valueName":"Both"
}
]
},
},
},
},
{
"src_code":"Active","tgt_code":null
}
]







Output:

[
{
"entity":
{
"attributes":
{
"type":"CustomField","url":"A"
}
"Metadata":
{
"valueSet":
{
"value":
[
{
"color":null,"default":false,"description":null,"isActive":null,"label":"None","urls":null,"valueName":"None"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Country","urls":null,"valueName":"Country"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Employee","urls":null,"valueName":"Employee"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Both","urls":null,"valueName":"Both"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Active","urls":null,"valueName":"Active"
}
]
},
},
},
}
]Preformatted text
14 REPLIES 14

KTsnap
New Contributor III

the expected Output is as follows:

[
{
"entity":
{
"attributes":
{
"type":"CustomField","url":"A"
}
"Metadata":
{
"valueSet":
{
"value":
[
{
"color":null,"default":false,"description":null,"isActive":null,"label":"None","urls":null,"valueName":"None"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Country","urls":null,"valueName":"Country"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Employee","urls":null,"valueName":"Employee"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Both","urls":null,"valueName":"Both"
},
{
"color":null,"default":false,"description":null,"isActive":null,"label":"Active","urls":null,"valueName":"Active"
}
]
},
},
},
}
]

As I said in my previous reply, enable Pass through in the Mapper. You’ll get the following result:

  {
    "entity": {
      "attributes": {
        "type": "CustomField",
        "url": "A"
      },
      "Metadata": {
        "valueSet": {
          "value": [
            {
              "color": null,
              "default": false,
              "description": null,
              "isActive": null,
              "label": "None",
              "urls": null,
              "valueName": "None"
            },
            {
              "color": null,
              "default": false,
              "description": null,
              "isActive": null,
              "label": "Country",
              "urls": null,
              "valueName": "Country"
            },
            {
              "color": null,
              "default": false,
              "description": null,
              "isActive": null,
              "label": "Employee",
              "urls": null,
              "valueName": "Employee"
            },
            {
              "color": null,
              "default": false,
              "description": null,
              "isActive": null,
              "label": "Both",
              "urls": null,
              "valueName": "Both"
            },
            {
              "color": null,
              "default": false,
              "description": null,
              "isActive": null,
              "label": "Active",
              "urls": null,
              "valueName": "Active"
            }
          ]
        }
      }
    }
  }
]

KTsnap
New Contributor III

Thanks Boston , its working Now.

ptaylor
Employee
Employee

@KTsnap When including JSON or code in a post to this forum, please use the “Preformatted text” feature of this editor. It’s the 6th icon from the left, and looks like this: </>

This greatly enhances readability, and also allows the content to be copy/pasted in a usable way. If you don’t use the feature on JSON, the editor will modify the double quote characters so that the resulting data isn’t usable if it’s copy/pasted. It also loses all the indentation, which makes it very hard to read.

Thanks.

KTsnap
New Contributor III

Hey thanks Taylor. i done the modification and indeed it helps in readability.