PostgreSQL中的SQL:
create table test.tt (text_text text[]);
insert into test.tt values('{111,4,101803,5}');
这是一个array text[]
。我想将其转换为json
这样:
{111:44,101803:5} as json
我尝试过array_to_json
,但是不能。
您可以使用json_object()
将其转换为JSON:
select json_object(text_text)
from test.tt;
请注意,这仅在所有值具有偶数个元素的情况下才有效!
以上收益
json_object
-----------------------------
{"111" : "4", "101803" : "5"}
在线示例:http : //rextester.com/STYJP65628
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句