> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set.md).

# JSON\_SET

## Syntax

```bnf
JSON_SET(json_doc, path, val[, path, val] ...)
```

## Description

Updates or inserts data into a JSON document, returning the result, or `NULL` if any of the arguments are `NULL` or the optional path fails to find an object.

An error will occur if the JSON document is invalid, the path is invalid or if the path contains a `*` or a wildcard\*\*.\*\*

`JSON_SET` can update or insert data, while [JSON\_REPLACE](/docs/server/reference/sql-functions/special-functions/json-functions/json_replace.md) can only update, and [JSON\_INSERT](/docs/server/reference/sql-functions/special-functions/json-functions/json_insert.md) only insert.

## Examples

```sql
SELECT JSON_SET(Priv, '$.locked', 'true') FROM mysql.global_priv
```

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/special-functions/json-functions/json_set.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
