I have a following json file and I'm looking for a way to extract object using object path using bash shell.
For example, if I say extract('production-ap/ap-northeast-1')
, then it will return me "accessKey": "OO"
, "accountID": "99"
.
I like bash shell scripting but have limited knowledge of it, please help!
Thanks
{
"production-ap": {
"ap-northeast-1": {
"accessKey": "OO",
"accountID": "99"
},
"ap-northeast-2": {
"accessKey": "AB",
"accountID": "12"
}
},
"production-eu": {
"eu-west-1": {
"accessKey": "CD",
"accountID": "34"
},
"us-east-1": {
"accessKey": "CD",
"accountID": "34"
}
},
"production-us": {
"us-east-1": {
"accessKey": "EF",
"accountID": "56"
},
"us-east-2": {
"accessKey": "EF",
"accountID": "56"
}
},
"stage-ap": {
"ap-northeast-1": {
"accessKey": "AK",
"accountID": "78"
},
"ap-northeast-2": {
"accessKey": "AK",
"accountID": "78"
}
},
"stage-eu": {
"eu-west-1": {
"accessKey": "AK",
"accountID": "55"
},
"eu-west-2": {
"accessKey": "AK",
"accountID": "55"
}
},
"stage-us": {
"us-east-1": {
"accessKey": "AK",
"accountID": "30"
},
"us-east-2": {
"accessKey": "AK",
"accountID": "30"
}
},
"private": {
"us-west-2": {
"accessKey": "z2",
"accountID": "52"
},
"us-west-1": {
"accessKey": "z2",
"accountID": "52"
}
}
}