From 9680a5f61ee15a40e4c3b1c23acf3197d50184fd Mon Sep 17 00:00:00 2001 From: islishude Date: Thu, 12 Sep 2024 16:02:51 +0800 Subject: [PATCH] core/types: fix json encoding for Request --- core/types/request.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/types/request.go b/core/types/request.go index 7b1cade26e..d8749c4f0d 100644 --- a/core/types/request.go +++ b/core/types/request.go @@ -18,6 +18,7 @@ package types import ( "bytes" + "encoding/json" "errors" "fmt" "io" @@ -94,6 +95,11 @@ func (r *Request) encode(w *bytes.Buffer) error { return r.inner.encode(w) } +// MarshalJSON marshals as JSON. +func (r *Request) MarshalJSON() ([]byte, error) { + return json.Marshal(r.inner) +} + // MarshalBinary returns the canonical encoding of the request. func (r *Request) MarshalBinary() ([]byte, error) { var buf bytes.Buffer