Skip to main content
Version: 8.1

jsonSet

This function is used by Ignition's Expression language.

Description​

Takes a JSON-friendly string, a path string, and value, and will return a new JSON-friendly string with the provided path set to the provided value. This is best used in conjunction with the Derived Tags writeback value.

Syntax​

jsonSet(json, path, value)

Parameters​

TypeParameterDescription
StringjsonThe JSON string. The string must be in a JSON friendly format.
StringpathThe path string.
ObjectvalueThe replacement for the value at the path.

Results​

String - A JSON friendly string with a new value set at the specified path.

Examples​

Code Snippet
// This example takes a JSON friendly string and sets the provided path to the given value. This would then return the string {'item':{'firstThing':1, 'secondThing':5}}

jsonSet("{'item':{'firstThing':1, 'secondThing':2}}", "item.secondThing", 5)