How to exclude some keys from an object? #51
Replies: 6 comments 4 replies
-
I think if we add set subtraction and the reduce projection it would be something like: |
Beta Was this translation helpful? Give feedback.
-
About what we thought together, the idea for me is to find a good function syntax to :
if possible using only 1 function. I understand that we could certainly find a way to do this with some mix and match of function already present in the grammar but how to find the right compromise between :
|
Beta Was this translation helpful? Give feedback.
-
I think I have a solid solution here: #25 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
So If I resume the need , consider the following two JSONs : Input:
Expected:
The operations on the input are :
Remove
Modify and so the complete jmespath expression will be :
It's not so difficult to create this kind of expression 😃 . |
Beta Was this translation helpful? Give feedback.
-
This recent issue also touches on this subject. |
Beta Was this translation helpful? Give feedback.
-
JMESPath Community 1.1 now supports this scenario indirectly. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is just a thought experiment, but how to exclude some keys from an object?
Maybe a convoluted expression using the existing
keys()
,values()
and the upcomingitems()
andfrom_items()
functions could do the trick. But Maybe we need a simpler syntax for that use case.We may need to introduce a
...
spread operator, and maybe a_
discard identifier.Consider the sample from the JMESPath front page.
Let’s return all location objects, without the
name
property, for instance:In the preceding expression the
multi-select-hash
looks like a destructuring syntax where_: name
discards thename
property and...@
uses a hypothetical spread operator that takes all remaining (non-discarded) properties.This would evaluate to:
Beta Was this translation helpful? Give feedback.
All reactions