一、json like 脚本
1.json类型like用法
select *
from risk_factor_attribute
where risk_factor_attribute_range->>'range' like '%-%';
2.json类型转换成text
select *
from risk_factor_attribute
where risk_factor_attribute_range::text like '% %';
二、json基础脚本
1.insert json数据
insert into test(id,range)
values
(1,'{"flag":"true","range":{"male":{"low":{"value":"<{{ lower }}","level":"-1"},"normal":{"value":"{{ lower }}-{{ upper }}","level":"0"},"high":{"value":">{{ upper }}","level":"+1"}},"female":{"very low":{"value":"<5","level":"-2"},"low":{"value":"{{ lower }}-4","level":"-1"},"normal":{"value":"{{ lower }}-{{ upper }}","level":"0"},"high":{"value":">{{ upper }}","level":"+1"}}}}');
2.查询json数据
select range ->> 'range' AS range
from test;