Skip to main content
JSON_SET

Sets a value for a specific field in JSON data

Updated over a week ago

Description

JSON_SET() modifies or adds a value to a specified field in a JSON object, identified by the JSON path. It's useful for updating or creating JSON data.

Syntax

JSON_SET(json, json_path, value)

Output

text

Variables

  1. json: The JSON object.

  2. json_path: The path to the specific field in the JSON object.

  3. value: The new value to set for the specified field.

Example

JSON_SET(`Company Details`, "$.date", TO_TEXT(TODAY()))

Company Details

JSON_SET

{"company_id": 1, "company_name": "ABC Inc.", "revenue": 500000, "location": "New York"}

{"company_id": 1, "company_name": "ABC Inc.", "revenue": 500000, "location": "New York", "date": "2023-12-14"}

{"company_id": 2, "company_name": "XYZ Corporation", "revenue": 750000, "location": "San Francisco"}

{"company_id": 2, "company_name": "XYZ Corporation", "revenue": 750000, "location": "San Francisco", "date": "2023-12-14"}

{"company_id": 3, "company_name": "LMN Enterprises", "revenue": 300000, "location": "Chicago"}

{"company_id": 3, "company_name": "LMN Enterprises", "revenue": 300000, "location": "Chicago", "date": "2023-12-14"}

Did this answer your question?