如何将行分成jsonb数组元素?
我有一个表:
create table table_name
(id varchar(255), details jsonb)
然后我需要将一些数组更新为“详细信息”
update table_name
set details = '["firstLineSecondLine", "ThirdLineFourthLine"]'::jsonb
where id = '1';
如何在“firstLineSecondLine”之间换行?
我需要我的身体是这样的:
"details": [
"firstLine
SecondLine",
"ThirdLine
FourthLine"
]
有什么想法吗?
I have a table:
create table table_name
(id varchar(255), details jsonb)
Then i need to update some array into "details"
update table_name
set details = '["firstLineSecondLine", "ThirdLineFourthLine"]'::jsonb
where id = '1';
How can i break lines between "firstLineSecondLine"?
I need thst my body be like:
"details": [
"firstLine
SecondLine",
"ThirdLine
FourthLine"
]
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSON 中引号内的文字换行符由
\n
表示。它们在输入和输出上都以这种方式表示,因此除了转换为纯文本或其他内容之外,您将无法使其以您想要的方式显示。另外,您的示例由于另一个原因而无效,它缺少外部卷曲。
literal newlines inside quotes in JSON are represented by
\n
. They are represented this way both on input and on output, so you will not able to get it to show up the way you want to other than converting to plain text, or something else.Also, your example is invalid for another reason, it is lacking the outer curlies.