gpt4 book ai didi

json - PostgreSQL:比较 json

转载 作者:行者123 更新时间:2023-11-29 11:56:17 24 4
gpt4 key购买 nike

<分区>

众所周知,目前 PostgreSQL 没有方法来比较两个 json 值。 json = json 之类的比较不起作用。但是之前将 json 转换为 text 呢?

然后

select ('{"x":"a", "y":"b"}')::json::text = 
('{"x":"a", "y":"b"}')::json::text

返回 true

同时

select ('{"x":"a", "y":"b"}')::json::text = 
('{"x":"a", "y":"d"}')::json::text

返回 false

我尝试了几种具有更复杂对象的变体,它按预期工作。

这个解决方案有什么问题吗?

更新:

需要兼容v9.3

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com