errmsg("wrong number of array subscripts")));
if (nkdims == 0)
- PG_RETURN_DATUM(CStringGetTextDatum("{}"));
+ goto close_object;
deconstruct_array(key_array,
TEXTOID, -1, false, 'i',
(void) pushJsonbValue(&result.parseState, WJB_VALUE, &v);
}
- result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
-
pfree(key_datums);
pfree(key_nulls);
pfree(val_datums);
pfree(val_nulls);
+close_object:
+ result.res = pushJsonbValue(&result.parseState, WJB_END_OBJECT, NULL);
+
PG_RETURN_POINTER(JsonbValueToJsonb(result.res));
}
SELECT json_object_agg(name, type) FROM foo;
ERROR: field name must not be null
-- json_object
+-- empty object, one dimension
+SELECT json_object('{}');
+ json_object
+-------------
+ {}
+(1 row)
+
+-- empty object, two dimensions
+SELECT json_object('{}', '{}');
+ json_object
+-------------
+ {}
+(1 row)
+
-- one dimension
SELECT json_object('{a,1,b,2,3,NULL,"d e f","a b c"}');
json_object
SELECT jsonb_object_agg(name, type) FROM foo;
ERROR: field name must not be null
-- jsonb_object
+-- empty object, one dimension
+SELECT jsonb_object('{}');
+ jsonb_object
+--------------
+ {}
+(1 row)
+
+-- empty object, two dimensions
+SELECT jsonb_object('{}', '{}');
+ jsonb_object
+--------------
+ {}
+(1 row)
+
-- one dimension
SELECT jsonb_object('{a,1,b,2,3,NULL,"d e f","a b c"}');
jsonb_object
-- json_object
+-- empty object, one dimension
+SELECT json_object('{}');
+
+-- empty object, two dimensions
+SELECT json_object('{}', '{}');
+
-- one dimension
SELECT json_object('{a,1,b,2,3,NULL,"d e f","a b c"}');
-- jsonb_object
+-- empty object, one dimension
+SELECT jsonb_object('{}');
+
+-- empty object, two dimensions
+SELECT jsonb_object('{}', '{}');
+
-- one dimension
SELECT jsonb_object('{a,1,b,2,3,NULL,"d e f","a b c"}');