diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-27 13:12:35 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-30 21:58:29 -0700 |
commit | cbf8ec9ae3212e9642385c034fe0b0846af6dfd0 (patch) | |
tree | 7f4a64fa5365ffd3b285f921c5f905754b3883b3 /encode.go | |
parent | d473f861a5c3a3112c83518eafbcda50e274b182 (diff) |
BREAKING CHANGE: reencode: Separate config from state
Diffstat (limited to 'encode.go')
-rw-r--r-- | encode.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -71,10 +71,9 @@ type Encoder struct { func NewEncoder(w io.Writer) *Encoder { re, ok := w.(*ReEncoder) if !ok { - re = &ReEncoder{ - Out: w, + re = NewReEncoder(w, ReEncoderConfig{ AllowMultipleValues: true, - } + }) } return &Encoder{ w: re, @@ -137,7 +136,7 @@ func encode(w io.Writer, val reflect.Value, escaper BackslashEscaper, quote bool return } // Use a sub-ReEncoder to check that it's a full element. - validator := &ReEncoder{Out: w, BackslashEscape: escaper} + validator := NewReEncoder(w, ReEncoderConfig{BackslashEscape: escaper}) if err := obj.EncodeJSON(validator); err != nil { panic(encodeError{&EncodeMethodError{ Type: val.Type(), @@ -175,7 +174,7 @@ func encode(w io.Writer, val reflect.Value, escaper BackslashEscaper, quote bool }}) } // Use a sub-ReEncoder to check that it's a full element. - validator := &ReEncoder{Out: w, BackslashEscape: escaper} + validator := NewReEncoder(w, ReEncoderConfig{BackslashEscape: escaper}) if _, err := validator.Write(dat); err != nil { panic(encodeError{&EncodeMethodError{ Type: val.Type(), |