Reputation: 63
I have the following JSON object,
[
{
"name" : "a1",
"value": null
},
{
"name" : "a2",
"value": 3,
}
{
"name" : "a1",
"value": 4
},
{
"name" : "a2",
"value": 6
}
]
I want a JMESPATH query that should return the following using jmespath query,
[
{
"name": "a1",
"value": [null, 4]
},
{
"name": "a2",
"value": [3, 6]
}
]
I have tried the naive way by getting the list of names and filtering the values from the name. But, I want to get the data with one query. Could someone help me here?
Upvotes: 1
Views: 839
Reputation: 39099
This is not possible for the moment being.
A proposition to include it has been added to the JMESPath enhancement proposal (JEP) repository though: Function proposal - groupBy(), and is currently discussed as there is an initiative to add more language features:
To give some context to the current state of things, the JMESPath spec has been purposefully static for a while, with no new language features being added. This was originally intended to give the JMESPath library authors a chance to catch up and allow their libraries to stabilize. That way you could have consistent behavior/semantics regardless of how you were using JMESPath.
I've let too much time pass without enhancing the spec, and there seems to be several consistent themes of features that users are requesting. I would like to address that now and am open to adding new functionality to JMESPath.
I would like to have a process in place where we define exactly how changes are proposed and added to JMESPath. I'd like this process to also include community involvement, so that anyone that wants to participate in these dicussions has the opportunity to do so. This will likely evolve over time as the process is refined.
Source: https://github.com/jmespath/jmespath.site/issues/94#issuecomment-1136192269
Upvotes: 1