我有几个 JSON 文件,结构略有不同(可以有多个“列”)
但它们看起来像这样:
[{"data":"redacted1","type":"unknown"},{"data":"","type":"unknown"},{"data":"[email protected]","type":"email"}]
[{"data":"redacted2","type":"unknown"},{"data":"","type":"unknown"},{"data":"[email protected]","type":"email"}]
[{"data":"redacted3","type":"unknown"},{"data":"","type":"unknown"},{"data":"[email protected]","type":"email"}]
我想把“type”换成自己的值,第三个数据指针是email,第一个是name,中间是junk,第三个已经有值了。
所以我希望它看起来像这样:
[{"data":"redacted1","type":"name"},{"data":"","type":"junk"},{"data":"[email protected]","type":"email"}]
[{"data":"redacted2","type":"name"},{"data":"","type":"junk"},{"data":"[email protected]","type":"email"}]
[{"data":"redacted3","type":"name"},{"data":"","type":"junk"},{"data":"[email protected]","type":"email"}]
我怎么能用 JQ 做到这一点?
给定
然后