summaryrefslogtreecommitdiff
path: root/encode.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-27 13:12:35 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-30 21:58:29 -0700
commitcbf8ec9ae3212e9642385c034fe0b0846af6dfd0 (patch)
tree7f4a64fa5365ffd3b285f921c5f905754b3883b3 /encode.go
parentd473f861a5c3a3112c83518eafbcda50e274b182 (diff)
BREAKING CHANGE: reencode: Separate config from state
Diffstat (limited to 'encode.go')
-rw-r--r--encode.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/encode.go b/encode.go
index 00848ed..e9c7ac6 100644
--- a/encode.go
+++ b/encode.go
@@ -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(),