tidwall / sjson

Set JSON values very quickly in Go
MIT License
2.4k stars 165 forks source link

Ability to delete all null values? #67

Closed ivanjaros closed 1 year ago

ivanjaros commented 1 year ago

I am butting heads with Go team's stance on the behavior of the omitempty tag where they treat empty map, slice and arrays as null values. Unfortunately all json encoding libraries parrot this blatant mistreatment of data so I have no choice but to avoid using omitempty tag altogether. This causes messages to be unnecessarily large for storage and transmission since now all fields will be present, no matter their value. To fix this problem I have to sacrifice performance, of better json encoders than the native one, for data cleanup and so I was wondering if it is possible for this library to recursively remove fields with null values from the json message? I've read an issue where you stated one should manipulate only one value at a time so I am wondering if you could maybe write a dedicated cleanup method for this purpose which could be optimized for specific use case of removing multiple values?

ivanjaros commented 1 year ago

ah, nevermind. that would probably remove null values that are desired and should be present.