I have this json text:
{
"buildStatus" : {
"status" : "ERROR",
"conditions" : [{
"status" : "OK",
"metricKey" : "bugs"
}, {
"status" : "ERROR",
"metricKey" : "test_success_density"
}, {
"status" : "OK",
"metricKey" : "vulnerabilities"
}
],
"periods" : []
}
}
I want to extract the overall status of the buildStatus, i.e the expected output was "ERROR"
"buildStatus" : {
"status" : "ERROR",
....
}
I tried the sed expression below, but it isn't working, it returns OK
:
status= sed -E 's/.*\"buildStatus\":.*\"status\":\"([^\"]*)\",.*/\1/' jsonfile
What am I doing wrong?