【发布时间】:2023-04-04 16:01:01
【问题描述】:
我有这种类型的数据:
[
"foo1: xxxxxx",
"foo2: xxxxxx",
"foo3: xxxxxx",
"foo4: xxxxxx",
"foo5: xxxxxx",
"foo6: xxxxxx"
]
我想用 jq 解析它。我试过了:
cat file.txt | jq '.foo1'
cat file.txt | jq '.[] | .foo1'
而且我每次都有这个错误:
jq: error (at <stdin>:8): Cannot index string with string "foo1"
exit status 5
但我不知道为什么!
有人告诉我我的 jq 命令有什么问题吗?
谢谢
【问题讨论】:
-
欢迎来到 SO。请根据minimal reproducible example 准则显示预期输出。
-
你有一个文字字符串数组,不能像地图一样检索