如何只选择JSON字符串的一部分

时间:2017-03-23 16:04:47

标签: postgresql

我有一个返回

的字段
{"nextPONumber":"3","poReportFooter":"This is the footer text for a purchase order report"}

我想拉

  

“这是采购订单报告的页脚文本”

SELECT
  modulesetting.value AS footer_value
FROM modulesetting
WHERE modulesetting.key='purchasing'

2 个答案:

答案 0 :(得分:1)

使用内置的JSON功能:

select
    modulesetting.value::json->>'poReportFooter'
from
    modulesetting
WHERE modulesetting.key='purchasing';

More info on the built-in JSON functions.

答案 1 :(得分:0)

猜测:

SELECT
  modulesetting.value->>'poReportFooter' AS footer_value
FROM modulesetting
WHERE modulesetting.key='purchasing'