I need to parse out specific information from the following JSON example bellow using jq. depending on the 'repo' I need to be able to parse from the properties array all 'key' & 'values' and associated with the repository. For example the repo "libs-production-local" would need to parse out any properties key with 'prod' in the string and its associated date value. has to be jq and run in .sh.
{
"results":[
{
"repo":"libs-production-local",
"path":"com/company/version",
"name":"sql.21.tar",
"type":"file",
"size":"40123",
"created":"date",
"created_by":"someone",
"modified":"date",
"modified_by":"someone",
"updated":"date",
"depth":4,
"actual_md5":"asdflsdf23a4324234",
"orginal_sha1":"sadlkfjsdklfjsadf",
"properties":[
{
"key":"deploy.uat",
"value":"2018-09-23"
},
{
"key":"deploy.prod.TLE",
"value":"2018-10-20"
},
{
"key":"deploy.prodXYZ",
"value":"2018-10-20"
},
{
"key":"deploy.prodPDQ",
"value":"2018-10-20"
},
{
"key":"deploy.prod.ABC",
"value":"2018-10-21"
},
{
"key":"businessUnit.name",
"value":"IndivdualName"
},
{
"key":"deploy.qa.ser2",
"value":"2018-10-20"
},
{
"key":"deploy.qa.ser1",
"value":"2018-11-23"
},
{
"key":"build.timestamp",
"value":"1510850899004"
}
],
"virtual_repos":[
"libs-production "
]
},
{
"repo":"libs-production-local",
"path":"com/company/version",
"name":"sql.22.tar",
"type":"file",
"size":"40123",
"created":"date",
"created_by":"someone",
"modified":"date",
"modified_by":"someone",
"updated":"date",
"depth":4,
"actual_md5":"asdflsdf23a4324234",
"orginal_sha1":"sadlkfjsdklfjsadf",
"properties":[
{
"key":"deploy.prodPDQ",
"value":"2018-10-22"
},
{
"key":"deploy.prodABC",
"value":"2018-10-20"
},
{
"key":"businessUnit.name",
"value":"IndivdualName"
},
{
"key":"deploy.qa",
"value":"2018-10-20"
},
{
"key":"deploy.dev",
"value":"2018-11-19"
}
],
"virtual_repos":[
"libs-production "
]
}
],
"range":{
"start_pos":0,
"end_pos":479,
"total":479
}
}
I've tried a number of ways to do this (including this one) and nothing works.
jq -r '.results[] | ( .properties |map(select(.key[] contains ("prod")) '