good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit b6c033f2 authored by a's avatar a
Browse files

jx encoder lazy

parent ab7f33dc
Branches
Tags
No related merge requests found
Pipeline #30863 passed
...@@ -327,19 +327,23 @@ func (c *callResponder) send(ctx context.Context, env *callEnv) (err error) { ...@@ -327,19 +327,23 @@ func (c *callResponder) send(ctx context.Context, env *callEnv) (err error) {
} else { } else {
e.Raw(cast) e.Raw(cast)
} }
case func(e *jx.Encoder) error:
err = cast(e)
default: default:
err = json.NewEncoder(e).EncodeWithOption(cast, func(eo *json.EncodeOption) { err = json.NewEncoder(e).EncodeWithOption(cast, func(eo *json.EncodeOption) {
eo.DisableNewline = true eo.DisableNewline = true
}) })
if err != nil {
return
}
} }
} else { } else {
e.Null() e.Null()
} }
}) })
} }
if env.err == nil && err != nil {
e.Field("error", func(e *jx.Encoder) {
jsonrpc.EncodeError(e, err)
})
}
}) })
// a json encoding error here is possibly fatal.... // a json encoding error here is possibly fatal....
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment