Better emptiness test for custom JSON serializer

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek
2021-11-01 20:12:35 +01:00
parent 120ad2d3ca
commit a845613d03

View File

@ -145,12 +145,12 @@ func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
} }
} }
func MarshalErrorJSONIsEmpty(_ unsafe.Pointer) bool { func MarshalErrorJSONIsEmpty(ptr unsafe.Pointer) bool {
return false return *((*error)(ptr)) == nil
} }
func MarshalErrorSliceJSONIsEmpty(_ unsafe.Pointer) bool { func MarshalErrorSliceJSONIsEmpty(ptr unsafe.Pointer) bool {
return false return len(*((*[]error)(ptr))) <= 0
} }
// WriteJSON writes an interface value encoded as JSON to w // WriteJSON writes an interface value encoded as JSON to w