且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JQ工具实用程序解析或查看JSON数据字段,其中字段名称带有“-"按键名称中的破折号

更新时间:2021-10-16 04:54:28

-"用于jq的求反.对于带有特殊字符(例如-")的键名,不能使用简化的".keyname"语法.有几种选择,但最可靠的方法是使用.["KEY NAME"]形式,当链接时,例如,可以将其缩写为["KEY NAME"]. .a["b-c"].a | .["b-c"]的简写.

"-" is used for negation in jq. For key names with special characters such as "-", one cannot use the simplified ".keyname" syntax. There are several alternatives, but the most robust is simply to use the form .["KEY NAME"], which can be abbreviated to ["KEY NAME"] when chained, e.g. .a["b-c"] is shorthand for .a | .["b-c"].

如有疑问,请显式使用管道.

If in doubt, use the pipe explicitly.

有关更多信息,请查阅jq手册和/或 https://github.com/stedolan/jq/wiki/FAQ

For further information, please consult the jq manual and/or https://github.com/stedolan/jq/wiki/FAQ