You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use (*json.Encoder).SetZeroizeNilSlice(true) can let the encoder encode nil slice as an empty json array [] instead of null
Why
If we have a nil slive []Type(nil), the encoder will encode it as null. Then the consumers will having trouble with it, they must to check if the field is null first.
A way to solve this problem is always alloc a zero length slice before encoding. However, I want my code be simplify but not fill with make([]Type, 0) every where.
Additional Information
This change should be completely backward compatible.
The options name is not good, maybe have to decide a better name later.