我有以下JSON数据
"cumulativeStatistics": [
{
"Mean_Test_Time_(ms)": 481.6876712328767,
"Response_bytes_per_second": 10514.456156404525,
"Errors": 0.0,
"testNumber": 1.0,
"TPS": 2.141001049970378,
"testDescription": "Some status",
"Mean_time_to_first_byte": 481.1034246575342,
"Tests": 1460.0,
"Peak_TPS": 4.0
},
{
"Mean_Test_Time_(ms)": 453.88211103495547,
"Response_bytes_per_second": 10507.254474105619,
"Errors": 0.0,
"testNumber": 2.0,
"TPS": 2.1395346108950557,
"testDescription": "Status Again",
"Mean_time_to_first_byte": 453.4825222755312,
"Tests": 1459.0,
"Peak_TPS": 4.0
}
我使用以下jq,除了Mean_Test_Time_(ms)之外,因为括号
能够输出除了Mean_Test_Time_(ms)之外的所有其他参数 cat sample.data | jq '.perf.cumulativeStatistics[0].Response_bytes_per_second'
它解释括号本身。所以当我使用Mean_Test_time_(ms)时,我得到以下错误
error: syntax error, unexpected '(', expecting $end
.perf.cumulativeStatistics[0].Mean_Test_Time_(ms)
如何摆脱这些禁忌?
谢谢!
答案 0 :(得分:1)
与Javascript一样,您可以使用括号来访问这些"有问题的"属性名称,如下所示:
jq '.perf.cumulativeStatistics[0]["Mean_Test_Time_(ms)"]' sample.data