Available in versions: Dev (3.20) | Latest (3.19) | 3.18

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

JSON_SET

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The MySQL style JSON_SET function is a function that adds (like JSON_INSERT) or replaces (JSON_REPLACE) a value in a JSON document, given a JSON path.

SELECT
  JSON_SET('{"a":1}', '$.a', 2),
  JSON_SET('{"a":1}', '$.b', 2)
create.select(
           jsonSet(val(json("{\"a\":1}")), "$.a", 2),
           jsonSet(val(json("{\"a\":1}")), "$.b", 2)).fetch();

The result would look like this:

+----------+---------------+
| json_set | json_set      |
+----------+---------------+
| {"a":2}  | {"a":1,"b":2} |
+----------+---------------+
jsonSet(val(json("{\"a\":1}")), "$.a", 2)

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo