I have a machine-generated JSON of the following form:
{
"detail": {
"container": {
"environment" : [
{'Name': 'ENV_VAR_A', 'Value': 'MyValA'},
{'Name': 'ENV_VAR_B', 'Value': 'MyValB'},
{'Name': 'ENV_VAR_C', 'Value': 'MyValC'}
]
}
}
}
I'd like to use JSON dot notation to access a particular element of the list environment
by matching on the Name
value, returning the Value
value. As this JSON is machine generated, I have no control over the order of elements within environment
, so something like
$.detail.container.environment[2].Value
would not necessarily work to retrieve the value MyValC
Is there a way, using dot notation, to retrieve a particular value from a list of homogeneous nested JSONs based on a string match of another value within that nested JSON?