c语言json加换行符,在JSON中“保留”换行符的好方法?

我正在构建一个Java Jersey 2 Rest API(抓取程序)。爬虫从文章中检索文本并以json格式返回。 API将在稍后由其他开发人员使用。在JSON中“保留”换行符的好方法?

所以我的问题是 - 我怎么能“保持”在我的JSON输出字符串中的换行符?处理这个问题(JSON输出)其他服务的

例子:

"text": "When Etsy bought Grand St. last April, . But that’s about to change. At the end of this month, Grand St. will stop processing orders and on October 1, listings on the site will become inactive. At that point, Grand St.’s site will just be a gallery of content and photos.\nThat’s because the Grand St. team has taken on a lot more projects at Etsy, so from a user experience and maintenance perspective, it made sense to move Grand St. away from commerce, Etsy Senior PR Manager Nicole Summer told TechCrunch.\n“We at Etsy and Grand St. have truly appreciated all the hard work from Grand St. makers, and we welcome them to learn more about joining the Etsy community,” Summer said. “The Grand St. team has become an integral part of the Etsy organization, working on innovative projects to help our sellers scale. We’re grateful to have them on board and excited to continue the work we’re doing to empower our sellers to achieve their creative business goals on their own terms.”\nFor background, Grand St. sells things like solar chargers, a smart light for nighttime bike rides and The Cash Cannon for making it rain. Before the acquisition, Grand St. had raised $1.3 million in seed funding from First Round Capital, David Tisch, Gary Vaynerchuk, betaworks, Collaborative Fund, MESA+, Quotidian Ventures, and Undercurrent.\nFeatured Image: Dennis Skley/Flickr UNDER A CC BY-ND 2.0 LICENSE",

你可以看到,他们使用的是\ n在他们的JSON。

+0

我觉得“\ N”(标准方式)是通过从服务端和客户端的JSON换行理解它,并从那里break语句很好的方式。 –

+0

谢谢:)问题是,JSON解析器(杰克逊)从字符串(\ n)中删除这些字符。任何提示如何防止这种情况? –

+0

看到我的答案在下面,让我知道如果它不工作。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值