Add 'ignore_nulls' option to row_to_json
Stephen Frost <sfrost@snowman.net>
Add 'ignore_nulls' option to row_to_json Provide an option to skip NULL values in a row when generating a JSON object from that row with row_to_json. This can reduce the size of the JSON object in cases where columns are NULL without really reducing the information in the JSON object. This also makes row_to_json into a single function with default values, rather than having multiple functions. In passing, change array_to_json to also be a single function with default values (we don't add an 'ignore_nulls' option yet- it's not clear that there is a sensible use-case there, and it hasn't been asked for in any case). Pavel Stehule
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +4 −2 |
| src/backend/catalog/system_views.sql | modified | +14 −0 |
| src/backend/utils/adt/json.c | modified | +15 −40 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.h | modified | +2 −6 |
| src/include/utils/json.h | modified | +0 −2 |
| src/test/regress/expected/json.out | modified | +58 −0 |
| src/test/regress/sql/json.sql | modified | +24 −0 |