在Postgres中,其中一个列的JSON数据发布在下面。
当我对该列进行'Select‘查询时,我希望将’lib-5dc422e9f21531f9dbc16fd0‘和’lib-5dc422e9153f2153f9dbc16fd0‘的JSON值替换为lib-One和lib-6等。
我对postgres很陌生,已经想了一段时间了。
基本上将任何lib-*-[0-9]值替换为lib-*-
{
"data":{
"Library":{
"Checkout":{
"invoiceId":"12dfdf454546",
"checkoutDetail":{
"invoiceTransactionId":"5ab422e9f21531f9dbc16fd6",
"invoicePaymentDetail":{
"objectId":"lib-One-5dc422e9f21531f9dbc16fd0",
"checkoutPeriods":[
{
"startDate":"2017-04-14T19:00:00.000",
"endDate":"2017-05-19T19:00:00.000"
}
],
"invoice":{
"objectId":"lib-Six-5dc422e9f21531f9dbc16fd0",
"checkObject":true
}
}
}
}
}
}
}发布于 2019-11-07 15:56:28
我会用字符串上的RegEx函数来解决这个问题:
SELECT
regexp_replace('<your data>'::text, '"(lib-.*?-)(.*?)"', '"\1"', 'g')::json as ahttps://stackoverflow.com/questions/58752111
复制相似问题