diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c
index 9151a13..f7138a6 100644
--- a/src/backend/utils/adt/jsonb.c
+++ b/src/backend/utils/adt/jsonb.c
@@ -1455,7 +1455,7 @@ jsonb_object_two_arg(PG_FUNCTION_ARGS)
 				 errmsg("wrong number of array subscripts")));
 
 	if (nkdims == 0)
-		PG_RETURN_DATUM(CStringGetTextDatum("{}"));
+		PG_RETURN_DATUM(jsonb_from_cstring("{}", 2));
 
 	deconstruct_array(key_array,
 					  TEXTOID, -1, false, 'i',
diff --git a/src/test/regress/expected/json.out b/src/test/regress/expected/json.out
index 0ced17e..502f983 100644
--- a/src/test/regress/expected/json.out
+++ b/src/test/regress/expected/json.out
@@ -1510,6 +1510,20 @@ INSERT INTO foo VALUES (999999, NULL, 'bar');
 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                      
diff --git a/src/test/regress/expected/jsonb.out b/src/test/regress/expected/jsonb.out
index 72fe808..4789e4e 100644
--- a/src/test/regress/expected/jsonb.out
+++ b/src/test/regress/expected/jsonb.out
@@ -1410,6 +1410,20 @@ INSERT INTO foo VALUES (999999, NULL, 'bar');
 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                    
diff --git a/src/test/regress/sql/json.sql b/src/test/regress/sql/json.sql
index 0d2c139..39f1b70 100644
--- a/src/test/regress/sql/json.sql
+++ b/src/test/regress/sql/json.sql
@@ -462,6 +462,12 @@ SELECT json_object_agg(name, type) FROM foo;
 
 -- 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"}');
 
diff --git a/src/test/regress/sql/jsonb.sql b/src/test/regress/sql/jsonb.sql
index b724f0a..4b24477 100644
--- a/src/test/regress/sql/jsonb.sql
+++ b/src/test/regress/sql/jsonb.sql
@@ -352,6 +352,12 @@ SELECT jsonb_object_agg(name, type) FROM foo;
 
 -- 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"}');
 
