I have the following JSON and try to filter it with JMESPath:
{
"loadingExperience": {
"id": "https://www.examle.com/a/",
"metrics": {
"CUMULATIVE_LAYOUT_SHIFT_SCORE": {
"percentile": 2,
"distributions": [
{
"min": 0,
"max": 10,
"proportion": 0.9659427443237902
},
{
"min": 10,
"max": 25,
"proportion": 0.030108588351431376
},
{
"min": 25,
"proportion": 0.0039486673247778855
}
],
"category": "FAST"
},
"EXPERIMENTAL_INTERACTION_TO_NEXT_PAINT": {
"percentile": 101,
"distributions": [
{
"min": 0,
"max": 200,
"proportion": 0.90151826015593
},
{
"min": 200,
"max": 500,
"proportion": 0.08329913828477642
},
{
"min": 500,
"proportion": 0.015182601559294217
}
],
"category": "FAST"
}
}
}
}
My expected output is the following, and the requirement is not to use names of certain metrics in JMESPath expression:
[
"CUMULATIVE_LAYOUT_SHIFT_SCORE": "FAST",
"EXPERIMENTAL_INTERACTION_TO_NEXT_PAINT": "FAST"
]
With *[].metrics[]|[0]
I get the full list of metrics with all values:
{
"CUMULATIVE_LAYOUT_SHIFT_SCORE": {
"percentile": 2,
"distributions": [
{
"min": 0,
"max": 10,
"proportion": 0.9659427443237902
},
{
"min": 10,
"max": 25,
"proportion": 0.030108588351431376
},
{
"min": 25,
"proportion": 0.0039486673247778855
}
],
"category": "FAST"
},
"EXPERIMENTAL_INTERACTION_TO_NEXT_PAINT": {
"percentile": 101,
"distributions": [
{
"min": 0,
"max": 200,
"proportion": 0.90151826015593
},
{
"min": 200,
"max": 500,
"proportion": 0.08329913828477642
},
{
"min": 500,
"proportion": 0.015182601559294217
}
],
"category": "FAST"
}
}
With *[].metrics[]|[0].*[].category
- only values of category
[
"FAST",
"FAST"
]
The solution seems to be very close, I tried multiple syntaxes, but still have no clue how to get the names of metrics. I even don't found any example for such task - all examples I found are about getting values, not labels.