Skip to main content

Encode JSON

Uncontrolled node

Overview​

Convert a workflow value into JSON text.

Encode JSON turns an object, list or scalar value into JSON text. Use it when the receiving input specifically expects a JSON string rather than structured data.

It runs when its output is needed, without a run event.

Inputs​

InputTypeDescription
valueDataThe value to encode.

Outputs​

OutputTypeDescription
jsonDataJSON text, or an object with an error field if encoding fails. A missing value produces no JSON text.

Example​

The object {"name":"Ada","active":true} becomes the text:

{"name":"Ada","active":true}

Text inputs are encoded as JSON string values, including their surrounding quotes. Encoding Hello produces "Hello"; it is not the same as To Text.

If an input is already JSON text, encoding it again adds another layer of quoting and escaping. Skip this node when the next node accepts the original object directly.

Errors​

Some values cannot be represented as JSON, such as an object referring back to itself. In that case, json contains an error object instead of text. Check the result before sending it onward.

Use Decode JSON to turn JSON text back into a workflow value.