json - 如何在下面的 json 文件中获取名称值
问题描述
[
{
"_class": "hudson.model.FreeStyleProject",
"name": "actual_build",
"url": "http://tepl.tallycloudinfra.com:8080/job/actual_build/",
"color": "blue",
"fullname": "actual_build"
},
{
"_class": "hudson.model.FreeStyleProject",
"name": "CIS_TEPL_QA_Deploy",
"url": "http://tepl.tallycloudinfra.com:8080/job/CIS_TEPL_QA_Deploy/",
"color": "blue",
"fullname": "CIS_TEPL_QA_Deploy"
},
{
"_class": "hudson.model.FreeStyleProject",
"name": "cktest",
"url": "http://tepl.tallycloudinfra.com:8080/job/cktest/",
"color": "red",
"fullname": "cktest"
},
{
"_class": "hudson.model.FreeStyleProject",
"name": "Create_New_DB_Structure",
"url": "http://tepl.tallycloudinfra.com:8080/job/Create_New_DB_Structure/",
"color": "blue",
"fullname": "Create_New_DB_Structure"
}
]
我在 jq 命令下尝试了这个错误。
错误:
jq -r '._class[].name' f1.json
jq: error (at f1.json:30): Cannot index array with string "_class"
jq -r '._class.name' f1.json
jq: error (at f1.json:30): Cannot index array with string "_class"
解决方案
有了您的意见,
jq '.[].name' f1.json
产量
"actual_build"
"CIS_TEPL_QA_Deploy"
"cktest"
"Create_New_DB_Structure"
推荐阅读
- python - 如何在他们选择的 seaborn 分布图中添加垂直线?[单个图中的多个分布]
- angular - 如何使用常量在以 Angular 7 编码的 UI 中显示标签
- c++ - 通过共享库替换 malloc
- compiler-errors - 我无法从 Ubuntu 交叉编译到 Windows 工作
- opengl - 如何在 sRGB 空间中输入颜色值?
- promise - 从附加到 Suitelet 的客户端脚本中设置现有记录的子列表字段
- kotlin - 在注解处理阶段获取kotlin fun参数的默认值
- amazon-s3 - 有没有办法在对我的 S3 存储服务器的请求中指定图像尺寸?
- php - 如果我经常实例化它们,只使用属性类会更好吗?
- newline - 如何让 Atom 停止添加这些新行