Source File
marshal_json.go
Belonging Package
github.com/grpc-ecosystem/grpc-gateway/v2/runtime
package runtimeimport ()// JSONBuiltin is a Marshaler which marshals/unmarshals into/from JSON// with the standard "encoding/json" package of Golang.// Although it is generally faster for simple proto messages than JSONPb,// it does not support advanced features of protobuf, e.g. map, oneof, ....//// The NewEncoder and NewDecoder types return *json.Encoder and// *json.Decoder respectively.type JSONBuiltin struct{}// ContentType always Returns "application/json".func (*JSONBuiltin) ( interface{}) string {return "application/json"}// Marshal marshals "v" into JSONfunc ( *JSONBuiltin) ( interface{}) ([]byte, error) {return json.Marshal()}// MarshalIndent is like Marshal but applies Indent to format the outputfunc ( *JSONBuiltin) ( interface{}, , string) ([]byte, error) {return json.MarshalIndent(, , )}// Unmarshal unmarshals JSON data into "v".func ( *JSONBuiltin) ( []byte, interface{}) error {return json.Unmarshal(, )}// NewDecoder returns a Decoder which reads JSON stream from "r".func ( *JSONBuiltin) ( io.Reader) Decoder {return json.NewDecoder()}// NewEncoder returns an Encoder which writes JSON stream into "w".func ( *JSONBuiltin) ( io.Writer) Encoder {return json.NewEncoder()}// Delimiter for newline encoded JSON streams.func ( *JSONBuiltin) () []byte {return []byte("\n")}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |