^
DETAIL: Expected string, but found "3".
CONTEXT: JSON data, line 1: {"abc":1,3...
+-- Recursion.
+SET max_stack_depth = '100kB';
+SELECT repeat('[', 10000)::json;
+ERROR: stack depth limit exceeded
+HINT: Increase the configuration parameter "max_stack_depth" (currently 100kB), after ensuring the platform's stack depth limit is adequate.
+SELECT repeat('{"a":', 10000)::json;
+ERROR: stack depth limit exceeded
+HINT: Increase the configuration parameter "max_stack_depth" (currently 100kB), after ensuring the platform's stack depth limit is adequate.
+RESET max_stack_depth;
-- Miscellaneous stuff.
SELECT 'true'::json; -- OK
json
(1 row)
COMMIT;
+select to_json(date '2014-05-28');
+ to_json
+--------------
+ "2014-05-28"
+(1 row)
+
+select to_json(date 'Infinity');
+ to_json
+------------
+ "infinity"
+(1 row)
+
+select to_json(timestamp 'Infinity');
+ to_json
+------------
+ "infinity"
+(1 row)
+
+select to_json(timestamptz 'Infinity');
+ to_json
+------------
+ "infinity"
+(1 row)
+
--json_agg
SELECT json_agg(q)
FROM ( SELECT $$a$$ || x AS b, y AS c,
{"b":"a2","c":5,"z":[{"f1":2,"f2":[1,2,3]},{"f1":5,"f2":[4,5,6]}]}]
(1 row)
-SELECT json_agg(q)
+SELECT json_agg(q ORDER BY x, y)
FROM rows q;
json_agg
-----------------------
{"x":3,"y":"txt3"}]
(1 row)
+UPDATE rows SET x = NULL WHERE x = 1;
+SELECT json_agg(q ORDER BY x NULLS FIRST, y)
+ FROM rows q;
+ json_agg
+--------------------------
+ [{"x":null,"y":"txt1"}, +
+ {"x":2,"y":"txt2"}, +
+ {"x":3,"y":"txt3"}]
+(1 row)
+
-- non-numeric output
SELECT row_to_json(q)
FROM (SELECT 'NaN'::float8 AS "float8field") q;
"two"
(1 row)
+SELECT test_json -> -1
+FROM test_json
+WHERE json_type = 'array';
+ ?column?
+----------
+ {"f1":9}
+(1 row)
+
SELECT test_json -> 2
FROM test_json
WHERE json_type = 'object';
(1 row)
+select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> -1;
+ ?column?
+----------
+
+(1 row)
+
select '{"a": [{"b": "c"}, {"b": "cc"}]}'::json -> 'z';
?column?
----------
{"turbines" : { "847001" : {"name" : "t15", "type" : "GE1043"}, "847002" : {"name" : "t16", "type" : "GE1043"}, "847003" : {"name" : "sub-alpha", "type" : "GESS90"} }}
(1 row)
+SELECT json_object_agg(name, type) FROM foo;
+ json_object_agg
+----------------------------------------------------------------
+ { "t15" : "GE1043", "t16" : "GE1043", "sub-alpha" : "GESS90" }
+(1 row)
+
+INSERT INTO foo VALUES (999999, NULL, 'bar');
+SELECT json_object_agg(name, type) FROM foo;
+ERROR: field name must not be null
-- json_object
-- one dimension
SELECT json_object('{a,1,b,2,3,NULL,"d e f","a b c"}');