如何将双重Qoutes更改为JSON中儿童对象的单个Qoutes?
我有一个JSON文本文件,需要将其导入到数据库中。除了一分钟的差异之外,我已经准备好了,即我需要将双重Qoutes更改为所有嵌套级别儿童的单Qoutes/使用JS的JSON值。
例如,
{"foo":"bar","ping":{"pong":"ping-pong","n":[{"a":1},{"b":2}]},"alpha":"beta","hello":"there!","you":"2"}
预期输出为:
{"foo":"bar","ping":{'pong':'ping-pong','n':[{'a':1},{'b':2}]}, "alpha":"beta","hello":"there!","you":"2"}
I have a JSON text files and I need to import it into a database. I have prepared it well except for a minute difference ie I need to change the double qoutes to single qoutes for all nested level children/values of JSON using jq.
For example,
{"foo":"bar","ping":{"pong":"ping-pong","n":[{"a":1},{"b":2}]},"alpha":"beta","hello":"there!","you":"2"}
and expected output is:
{"foo":"bar","ping":{'pong':'ping-pong','n':[{'a':1},{'b':2}]}, "alpha":"beta","hello":"there!","you":"2"}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将任何JSON对象变成JSON编码的字符串使用JQ的
tojson
或@json
functions:demo
demo
To turn any JSON object into a JSON-encoded string use jq's
tojson
or@json
functions:Demo
Demo
Both produce