Bet*_*eto 2 arrays bash json count jq
我想在shell脚本中获取JSON中向量的大小,但是我只得到每个向量字符串的大小,例如:
#!/bin/bash
j='{"Names": { "names": ["marry", "jason", "frank","kelly"] }}'
echo "$j" | jq -r ".Names | .names[] | length"
Run Code Online (Sandbox Code Playgroud)
输出为:
5
4
5
4
Run Code Online (Sandbox Code Playgroud)
但我想得到4,即向量中的项目数量。
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |