mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -10309,11 +10309,13 @@ table2-mapping
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>row_to_json(record [, pretty_bool])</literal>
|
||||
<literal>row_to_json(rowval record [, pretty bool [, ignore_nulls bool] ])</literal>
|
||||
</entry>
|
||||
<entry>
|
||||
Returns the row as a JSON object. Line feeds will be added between
|
||||
level-1 elements if <parameter>pretty_bool</parameter> is true.
|
||||
level-1 elements if <parameter>pretty_bool</parameter> is true. Elements
|
||||
with NULL values will be skipped when <parameter>ignore_nulls</parameter>
|
||||
is true.
|
||||
</entry>
|
||||
<entry><literal>row_to_json(row(1,'foo'))</literal></entry>
|
||||
<entry><literal>{"f1":1,"f2":"foo"}</literal></entry>
|
||||
|
Reference in New Issue
Block a user