Reputation: 1163
I have the following JSON data
"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
}
I'm using the following jq that's able to get out every other parameter except Mean_Test_Time_(ms) because of the brackets
cat sample.data | jq '.perf.cumulativeStatistics[0].Response_bytes_per_second'
It's interpretting the brackets itself. So when I use Mean_Test_time_(ms) with that command, I get the following error
error: syntax error, unexpected '(', expecting $end
.perf.cumulativeStatistics[0].Mean_Test_Time_(ms)
How do I escape these paranthesis?
Thanks!
Upvotes: 1
Views: 3670
Reputation: 158130
Like in Javascript, you can use brackets to access such "problematic" property names, like this:
jq '.perf.cumulativeStatistics[0]["Mean_Test_Time_(ms)"]' sample.data
Upvotes: 3