如何删除jq输出中的双引号以在bash中解析json文件? [英] How to remove double-quotes in jq output for parsing json files in bash?

查看:49
本文介绍了如何删除jq输出中的双引号以在bash中解析json文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jq 解析 JSON 文件,如图所示 此处.但是,字符串值的结果按预期包含双引号",如下所示:

I'm using jq to parse a JSON file as shown here. However, the results for string values contain the "double-quotes" as expected, as shown below:

$ cat json.txt | jq '.name'
"Google"

如何通过管道将其传输到另一个命令中以删除"?所以我得到

How can I pipe this into another command to remove the ""? so I get

$ cat json.txt | jq '.name' | some_other_command
Google

我可以使用什么some_other_command?

推荐答案

使用 -r(或 --raw-output)选项发出原始字符串作为输出:

Use the -r (or --raw-output) option to emit raw strings as output:

jq -r '.name' <json.txt

这篇关于如何删除jq输出中的双引号以在bash中解析json文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆