From 95d737ff45a38809130a2c633d9e6bc26c825036 Mon Sep 17 00:00:00 2001 From: Stephen Frost Date: Thu, 11 Sep 2014 21:23:51 -0400 Subject: 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 --- doc/src/sgml/func.sgml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3a7cfa93c27..7195df85ff5 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10309,11 +10309,13 @@ table2-mapping - row_to_json(record [, pretty_bool]) + row_to_json(rowval record [, pretty bool [, ignore_nulls bool] ]) Returns the row as a JSON object. Line feeds will be added between - level-1 elements if pretty_bool is true. + level-1 elements if pretty_bool is true. Elements + with NULL values will be skipped when ignore_nulls + is true. row_to_json(row(1,'foo')) {"f1":1,"f2":"foo"} -- cgit v1.2.3