jmespath.site
jmespath.site copied to clipboard
[Proposal] Add functions `remove_empty_fields` `remove_null_fields`
Proposal for adding built-in functions remove_empty_fields and remove_null_fields which would be useful to remove fields of an object that are empty or have null value.
e.g. if we have a json like this
{'a':1, 'b':'', 'c': null}
we call
remove_empty_fields(@)
Result
{'a':1}
if we call
remove_null_fields(@)
Result
{'a':1, 'b':''}
Hi, any update on this?
Discarding null values is a surprisingly frequently requested feature from JMESPath.
The canonical answer is to use the merge() function and let external deserializers discard / irgnore those values.
That said, we are considering adding this to JMESPath Community.
Thanks to the new items(), from_items() and zip() functions, however, you can do this today:
Given:
{ "a": 1, "b": "", "c": null }
The following expressions can be useful:
from_items( items(@) [? @[1]!=`null` ] )returns `` { "a": 1, "b": "" }from_items( items(@) [? @[1]!='' ] )returns `` { "a": 1, "c": null }from_items( items(@) [? @[1] ] )returns `` { "a": 1 }
See this Wiki page for more details.
Uploading json-to-base64-converter.txt…
Uploading json-decode-online.json…
Uploading export-verified-contractaddress-opensource-license (1).csv…
Uploading source-code-viewer.txt…
Uploading export-verified-contractaddress-opensource-license.csv…
Uploading export-address-token-0xc0e6ad13bd58413ed308729b688d601243e1cf77.csv…
Uploading url.json…
Uploading json-to-base64-converter (1).txt…
@deenie1 i think you inadvertently uploaded exported files.
Apologies I don't have any clue what I'm doing? I did not evens no I did what u said I did, sorry. Sent from my Huawei Mobile-------- Original Message --------Subject: Re: [jmespath/jmespath.site] [Proposal] Add functions remove_empty_fields remove_null_fields (Issue #106)From: Daniel Gutson To: "jmespath/jmespath.site" CC: Nixx ,Mention
@deenie1 i think you inadvertently uploaded exported files.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>