使用 jq 获取带括号的值

Using jq to fetch a value with a bracket

我有以下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) 之外的所有其他参数
 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)

我该如何逃避这些括号?

谢谢!

就像在 Javascript 中一样,您可以使用方括号访问这样的 "problematic" 属性 名称,例如:

jq '.perf.cumulativeStatistics[0]["Mean_Test_Time_(ms)"]' sample.data