Understanding the new JSON capabilities in Postgres 16
Learn about the latest new features introduced in Postgres 16 for working with JSON data
We’re excited to announce that Neon now supports Postgres 16. This latest release includes several performance improvements and developer experience enhancements. One of the most anticipated features is the expanded support for SQL/JSON syntax, including:
JSON_ARRAY(): Constructs a JSON array.
JSON_ARRAYAGG(): Aggregates input values into a JSON array.
IS JSON: A predicate to determine if a given value is a valid JSON.
In this article, we will cover these new functions and predicates that you can try out on Neon today.
json_array() function is designed for constructing a JSON array. There are two main usages:
From a series of values:
From the outcome of a
json_arrayagg() function essentially behaves like the
json_array() function but is designed to operate as an aggregate function. To understand the difference between
json_array() functions, let’s consider the following example.
json_array(), the query will return a list of arrays that include the last names:
json_arrayagg(), the query returns one array of all last names:
IS JSON Predicate
IS JSON predicate is introduced to test if an expression can be parsed as JSON and possibly of a specified type.
Testing various JSON types:
Testing arrays with unique keys:
Postgres 16 introduces many improvements and features, some of which were contributed by the Neon Postgres team (Heikki Linnakangas, Matthias van de Meent, Tristan Partin). We’re excited about this new version, which you can try it out on Neon today.
If you have any questions or feedback, please reach out to us in our community forum. We’d love to hear from you.
Also, make sure to subscribe below if you would like to be notified of new content we publish on our blog.