mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
JSON generation improvements.
This adds the following: json_agg(anyrecord) -> json to_json(any) -> json hstore_to_json(hstore) -> json (also used as a cast) hstore_to_json_loose(hstore) -> json The last provides heuristic treatment of numbers and booleans. Also, in json generation, if any non-builtin type has a cast to json, that function is used instead of the type's output function. Andrew Dunstan, reviewed by Steve Singer. Catalog version bumped.
This commit is contained in:
@ -100,6 +100,18 @@ FROM rows q;
|
||||
|
||||
SELECT row_to_json(row((select array_agg(x) as d from generate_series(5,10) x)),false);
|
||||
|
||||
--json_agg
|
||||
|
||||
SELECT json_agg(q)
|
||||
FROM ( SELECT $$a$$ || x AS b, y AS c,
|
||||
ARRAY[ROW(x.*,ARRAY[1,2,3]),
|
||||
ROW(y.*,ARRAY[4,5,6])] AS z
|
||||
FROM generate_series(1,2) x,
|
||||
generate_series(4,5) y) q;
|
||||
|
||||
SELECT json_agg(q)
|
||||
FROM rows q;
|
||||
|
||||
-- non-numeric output
|
||||
SELECT row_to_json(q)
|
||||
FROM (SELECT 'NaN'::float8 AS "float8field") q;
|
||||
|
Reference in New Issue
Block a user