diff --git a/encode.go b/encode.go index c517382..0e5652c 100644 --- a/encode.go +++ b/encode.go @@ -84,7 +84,9 @@ func (e *Encoder) encodeWithOption(ctx *encoder.RuntimeContext, v interface{}, o } else { buf = buf[:len(buf)-1] } - buf = append(buf, '\n') + if !ctx.Option.DisableNewline { + buf = append(buf, '\n') + } if _, err := e.w.Write(buf); err != nil { return err } diff --git a/internal/encoder/option.go b/internal/encoder/option.go index 12c58e4..5a78788 100644 --- a/internal/encoder/option.go +++ b/internal/encoder/option.go @@ -24,6 +24,7 @@ type Option struct { Context context.Context DebugOut io.Writer DebugDOTOut io.WriteCloser + DisableNewline bool } type EncodeFormat struct {