# 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.

Information noteYou can add any number of name-value pairs with JsonSet.

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](https://datatracker.ietf.org/doc/html/rfc6901). 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. |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/JsonSet.htm)

#### Example: Valid JSON, path, and value

| Example | Result |
| --- | --- |
| `JsonSet('{}','/a','"b"')` | Returns '{"a":"b"}' |
| `JsonSet('[]','/0','"x"')` | Returns '["x"]' |
| `JsonSet('"abc"','','123')` | Returns 123 |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/JsonSet.htm)

#### Example: Invalid JSON, path, or value

| Example | Result | Description |
| --- | --- | --- |
| `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. |

See also:

* [IsJson - script and chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/IsJson.htm)

* [JsonGet - script and chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/JsonGet.htm)