如何在 postgres 的 jsonb 中获取 属性 的长度?

How can I get the length of a property in a jsonb in postgres?

product
---------------------------
{"id":1, "code": "1231313"}

这是我进行的查询,但它不起作用

SELECT * FROM public.order WHERE "product" ->> LENGTH('code') = '7';

我想知道如何从 jsonb 中获取此 属性 值的长度,请帮助我,谢谢。

下面是使用 ->> 运算符从类型为 JSON(B) 的列中提取字段,然后应用 length() 获取文本长度的方法。

select * from public.order where length(product->>'code') >= 7

查看各种 operators/functions 从 JSON(B) 列类型获取数据,Postgresql documentation