mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
Marshalling null instead of empty slice in Raw().
This commit is contained in:
+9
-2
@@ -46,10 +46,17 @@ func (w *Writer) RawString(s string) {
|
||||
// RawByte appends raw binary data to the buffer or sets the error if it is given. Useful for
|
||||
// calling with results of MarshalJSON-like functions.
|
||||
func (w *Writer) Raw(data []byte, err error) {
|
||||
if w.Error == nil && err != nil {
|
||||
if w.Error != nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch {
|
||||
case err != nil:
|
||||
w.Error = err
|
||||
} else if w.Error == nil {
|
||||
case len(data) > 0:
|
||||
w.Buffer.AppendBytes(data)
|
||||
default:
|
||||
w.RawString("null")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user