create schema test_json_keys;
set current_schema to 'test_json_keys';
SELECT JSON_KEYS('{"a":"t1"}');
 json_keys 
-----------
 ["a"]
(1 row)

SELECT JSON_KEYS('{"a":"t1","b":"t2"}');
 json_keys  
------------
 ["a", "b"]
(1 row)

SELECT JSON_KEYS('{"a":12}');
 json_keys 
-----------
 ["a"]
(1 row)

SELECT JSON_KEYS('{"a":12,"b":34}');
 json_keys  
------------
 ["a", "b"]
(1 row)

SELECT JSON_KEYS('{"a":123,"b":{"c":"qwe"}}');
 json_keys  
------------
 ["a", "b"]
(1 row)

SELECT JSON_KEYS('{"电子科技大学":123}');
    json_keys     
------------------
 ["电子科技大学"]
(1 row)

SELECT JSON_KEYS('{efguewfioegwgf}');
ERROR:  Invalid JSON text in argument 1 to function json_keys.
CONTEXT:  referenced column: json_keys
SELECT JSON_KEYS('');
ERROR:  Invalid JSON text in argument 1 to function json_keys.
CONTEXT:  referenced column: json_keys
SELECT JSON_KEYS();
ERROR:  function json_keys() does not exist
LINE 1: SELECT JSON_KEYS();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
CONTEXT:  referenced column: json_keys
SELECT JSON_KEYS(NULL);
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('{"a":123,"b":{"c":"qwe"}}',NULL);
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS(NULL,'$[0]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('{}');
 json_keys 
-----------
 []
(1 row)

SELECT JSON_KEYS('[]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('[1,2,3,4]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('[1,2,[114,514],4]','$[2]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS(true);
ERROR:  Invalid data type for JSON data in argument 1 to function json_keys
CONTEXT:  referenced column: json_keys
SELECT JSON_KEYS(true,false);
ERROR:  function json_keys(boolean, boolean) does not exist
LINE 1: SELECT JSON_KEYS(true,false);
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
CONTEXT:  referenced column: json_keys
SELECT JSON_KEYS('{"a":1,"b":{"c":2}}','$.b');
 json_keys 
-----------
 ["c"]
(1 row)

SELECT JSON_KEYS('{"a":1,"b":{"c":{"d":114},"d":514}}','$.b.c');
 json_keys 
-----------
 ["d"]
(1 row)

SELECT JSON_KEYS('[1,2,{"a":1,"b":{"c":2}},4]','$[2]');
 json_keys  
------------
 ["a", "b"]
(1 row)

SELECT JSON_KEYS('{"a":1,"b":{"c":2}}','$.z');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('[1,2,{"a":1,"b":{"c":2}},4]','$[8]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('{"a":1,"b":{"c":2}}','$[0]');
 json_keys 
-----------
 
(1 row)

SELECT JSON_KEYS('{"a":1,"b":{"c":2}}','$');
 json_keys  
------------
 ["a", "b"]
(1 row)

select json_keys('{"a":1,"b":2,"a":1}');
 json_keys  
------------
 ["a", "b"]
(1 row)

select json_keys('{"c":{"a":1,"b":2,"a":1},"z":2}','$.c');
 json_keys  
------------
 ["a", "b"]
(1 row)

select json_keys('{"d":1,"b":2,"a":1}');
    json_keys    
-----------------
 ["a", "b", "d"]
(1 row)

create table student(name json);
insert into student (name) value(json_keys('{"a":123,"b":{"c":"qwe"}}'));
select name from student;
    name    
------------
 ["a", "b"]
(1 row)

drop schema test_json_keys cascade;
NOTICE:  drop cascades to table student
reset current_schema;