Skip to main content
All CollectionsWrk Action LibraryText
Add a new field to a JSON
Add a new field to a JSON
Wrk Product avatar
Written by Wrk Product
Updated over 8 months ago

Add a new field to a JSON. This Wrk Action will allow you to take an existing JSON object and add a new field to it. By default this field will be added as a string to the top level of the object.

To specify a different location to add the field you can use jsonpath to specify the object you would like to add it to instead.

To add a value as a integer, boolean, object, or array you can select "Add field value without quotes?".

Application

  • Text

Inputs (what you have)

Name

Description

Data Type

Required?

Example

Original JSON

The JSON you would like to add a field to

Text (Long)

Yes

{“field1”:”value1”}

New field name

The name of the new field you would like to add

Text (Short)

Yes

field2

New field value

The value of the new field you would like to add

Text (Long)

Yes

value2

JSONPath location to add new field

The JSONpath to the object where you would like to have the new field added.

Text(short)

No

Add field value without quotes?

Select true if you would like to add the new field value without quotation marks. This is ideal for adding numbers, booleans, lists, objects, or strings that already contain quotes

True or False

No

Overwrite existing field?

Select true if you would like the Wrk Action to replace a existing field name with the new field value. If false will leave the original value in the field

True or False

No

Note: the value of inputs can either be a set value in the configuration of the Wrk Action within the Wrkflow, or a variable from the Data library section. These variables in the Data library section are the outputs of previous Wrk Actions in the Wrkflow.

Outputs (what you get)

Name

Description

Data Type

Required?

Example

Updated JSON

Text (Long)

Yes

{“field1”:”value1”, “field2”:”value2”}

Outcomes

Name

Description

Success

This status is selected if details are extracted from the JSON.

Impossible to Complete

This status is selected in the event of the following scenarios:

  • Updated JSON is not in JSON format

Requirements

  • N/A

Did this answer your question?