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 object attribute access with -> or ->>

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

JSON object attributes can be accessed by key as follows:

SELECT
  '{"a":1}'::json->'a'
create.select(jsonGetAttribute(json("{\"a\":1}"), "a"))
      .fetch();

The result would look like this:

+--------------------+
| json_get_attribute |
+--------------------+
| 1                  |
+--------------------+

The API is PostgreSQL inspired, and as such, there are two ways of accessing attributes:

jsonGetAttribute(json("{\"a\":1}"), "a")

References to this page

Feedback

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

The jOOQ Logo