I was fairly disappointed I had to make this Ansible filter last night- all it does is exclude object properties with undefined/empty values. It lets me have a full, flush object structure, but defaults for each property be empty, and if so empty, not end up being defined at all. If `omit` (the undefined of Ansible) properly omitted itself during a to_json
filter, all would be well, but Ansible doesn't seem to have any way to un-define a property what-so-ever.https://github.com/rektide/compfuzor/blob/master/library/filter_plugins/ignore_empty.py
I had a ton of different attempts to work out something similar without writing my own filter. My memory isn't great but I think I had some reject filters that worked, and had some interesting object generators that I thought would work, but ultimately I kept ending up with more generators and perhaps it was just me but I didn't see any way to reconstitute them, and I kept ending up with weird magic strings for values.