opengauss对json和jsonb操作的兼容性

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--                       json和jsonb操作符
-- select '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::json->2;
-- select '{"a": {"b":"foo"}}'::json->'a';                  -- 支持   ->
-- SELECT '[1,2,3]'::json->>2;                             
-- SELECT '{"a":1,"b":2}'::json->>'b';                      -- 支持   ->>
-- SELECT '{"a": {"b":{"c": "foo"}}}'::json #> '{a,b}';          -- 支持 #>
-- SELECT '{"a":[1,2,3],"b":[4,5,6]}'::json #>> '{a,2}';      -- 支持 #>>
-- SELECT '{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb;      -- 支持   @>
-- SELECT '{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb;      -- 支持   <@
-- SELECT '{"a":1, "b":2}'::jsonb ? 'b';                    -- 支持   ?
-- SELECT '{"a":1, "b":2, "c":3}'::jsonb ?| array['b', 'c'];-- 支持   ?|
-- SELECT '["a", "b"]'::jsonb || '["c", "d"]'::jsonb;       -- 不支持 ||
-- SELECT '{"a": "b"}'::jsonb - 'a';                        -- 不支持 -
-- SELECT '["a", {"b":1}]'::jsonb #- '{1,b}';               -- 不支持 #-
 
 
--                   json和jsonb操作函数
-- SELECT to_json('Fred said "Hi."'::text);                                         -- 支持   to_json
-- SELECT array_to_json('{{1,5},{99,100}}'::int[]);                     -- 支持   array_to_json
-- SELECT row_to_json(row(1,'foo'));                                    -- 支持   row_to_json
-- SELECT json_build_array(1,2,'3',4,5);                                -- 支持   json_build_array
-- SELECT json_build_object('foo',1,'bar',2)                            -- 支持   json_build_object
-- SELECT json_agg(1);                                                                          -- 支持   json_agg
-- SELECT json_object_agg(2,1);                                                                 -- 支持   json_object_agg
-- SELECT json_object('{a, 1, b, "def", c, 3.5}');     
-- SELECT json_object('{{a, 1},{b, "def"},{c, 3.5}}');                  -- 支持   json_object
-- SELECT json_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]');   -- 支持   json_array_length
-- select * from json_each('{"a":"foo", "b":"bar"}');                       -- 支持   json_each
-- select * from json_each_text('{"a":"foo", "b":"bar"}');          -- 支持   json_each_text
-- SELECT json_extract_path('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}','f4'); -- 支持   json_extract_path
-- SELECT json_extract_path_text('{"f2":{"f3":1},"f4":{"f5":99,"f6":"foo"}}','f4', 'f6'); -- 支持   json_extract_path_text
-- SELECT json_object_keys('{"f1":"abc","f2":{"f3":"a", "f4":"b"}}');       -- 支持   json_object_keys
-- create type jpop as (a text, b int, c bool);
-- select * from json_populate_record(null::jpop, '{"a":1,"b":2}');     -- 支持 json_populate_record
-- create type jpop as (a text, b int, c bool);
-- select * from json_populate_recordset(null::jpop, '[{"a":1,"b":2},{"a":3,"b":4}]');  -- 支持 json_populate_recordset
-- select * from json_array_elements('[1,true, [2,false]]');     -- 支持   json_array_elements
-- select * from json_array_elements_text('["foo", "bar"]');     -- 支持   json_array_elements_text
-- SELECT json_typeof('-123.4'); -- 支持   json_typeof
-- select * from json_to_record('{"a":1,"b":"foo","c":"bar"}',true) as x(a int, b text, d text); -- 支持 json_to_record
-- select * from json_to_recordset('[{"a":1,"b":"foo"},{"a":2,"c":"bar"}]') as x(a int, b text); -- 不支持 json_to_recordset
-- SELECT json_strip_nulls('[{"f1":1,"f2":null},2,null,3]');        -- 不支持 json_strip_nulls
-- select * from  json_array_elements_text('[1,true,[1,[2,3]],null]');            -- 支持 json_array_elements_text
-- select json_extract_path_text_op('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}', 'f4','f6');  -- 不支持 json_extract_path_text_op
 
--
-- SELECT jsonb_exists('{"a":1,"b":2}'::jsonb, 'a');                        -- 支持 jsonb_exists
-- select jsonb_set('{"name":"ss","age":100,"die":true}' ,'{name}','"t5t"');    -- 不支持 jsonb_set
-- SELECT jsonb_agg(1);                                                                         -- 不支持 jsonb_agg
-- SELECT jsonb_object_agg(2,1);                                                                -- 不支持 jsonb_object_agg
-- SELECT jsonb_object('{a, b}', '{1,2}');                              -- 支持   jsonb_object
-- SELECT jsonb_array_length('[1,2,3,{"f1":1,"f2":[5,6]},4]');  -- 支持   jsonb_array_length
-- SELECT jsonb_build_object('foo',1,'bar',2);                      -- 不支持 jsonb_build_object
-- select * from jsonb_each('{"a":"foo", "b":"bar"}');                  -- 支持   jsonb_each
-- select * from jsonb_each_text('{"a":"foo", "b":"bar"}');         -- 支持   jsonb_each_text
-- SELECT jsonb_object_keys('{"f1":"abc","f2":{"f3":"a", "f4":"b"}}');      -- 支持   jsonb_object_keys
-- select * from json_populate_recordset(null::jpop, '[{"a":1,"b":2},{"a":3,"b":4}]');  -- 支持 jsonb_populate_recordset
-- select * from jsonb_populate_record(null::jpop, '{"a":1,"b":2}');    -- 支持 jsonb_populate_record
-- SELECT jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0,f1}','[2,3,4]', false);   -- 不支持 jsonb_set
-- SELECT jsonb_pretty('[{"f1":1,"f2":null},2,null,3]');                -- 不支持 jsonb_pretty
-- select json_array_elements('[1,true,[1,[2,3]],null]');               -- 支持 json_array_elements
-- select jsonb_array_elements('[1,true,[1,[2,3]],null]');              -- 支持 jsonb_array_elements
-- select * from jsonb_to_record('{"a":1,"b":"foo","c":"bar"}',true) as x(a int, b text, d text); -- 不支持 jsonb_to_record
-- select * from  jsonb_array_elements_text('[1,true,[1,[2,3]],null]');             -- 支持 jsonb_array_elements_text
-- select jsonb_extract_path_text_op('{"f2":{"f3":1},"f4":{"f5":99,"f6":"stringy"}}', 'f4','f6'); -- 不支持 jsonb_extract_path_text_op

  

posted @   ☞@_@  阅读(302)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
点击右上角即可分享
微信分享提示