Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

JsonSet - script and chart function

JsonSet() modifies a string containing JSON (JavaScript Object Notation) data. It can set or insert a JSON value with the new location specified by the path. The data must be valid JSON but can contain extra spaces or newlines.

Syntax:  

value JsonSet(json, path, value)

Return data type: dual

Arguments
Argument Description
json String containing JSON data.
path

The path must be specified according to RFC 6901. This allows buildup of properties inside JSON data without using complex substring or index functions and concatenation.

value The new string value in JSON format.
Example: Valid and invalid chart expressions
Example Result
JsonSet( '{}','/a','"b"' ) Returns {"a":"b"}
JsonSet( '[]','/0','"x"' ) Returns ["x"]
JsonSet( '"abc"','','123' ) Returns 123
JsonSet( '"abc"','/x','123' ) Returns null. The path does not point to a valid part of the JSON data.
JsonSet( '{"a":{"b":"c"}}','a/b','"x"' ) Returns null. The path is invalid.
JsonSet( '{"a":"b"}','/a','abc' ) Returns null. The value is not valid JSON. A string must be enclosed in quotes.

Example - JsonSet fundamentals

See also:

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!