easyjson: github.com/mailru/easyjson Index | Files | Directories

package easyjson

import "github.com/mailru/easyjson"

Package easyjson contains marshaler/unmarshaler interfaces and helper functions.


Package Files

helpers.go raw.go unknown_fields.go

func Marshal Uses

func Marshal(v Marshaler) ([]byte, error)

Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied from a chain of smaller chunks.

func MarshalToHTTPResponseWriter Uses

func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bool, written int, err error)

MarshalToHTTPResponseWriter sets Content-Length and Content-Type headers for the http.ResponseWriter, and send the data to the writer. started will be equal to false if an error occurred before any http.ResponseWriter methods were actually invoked (in this case a 500 reply is possible).

func MarshalToWriter Uses

func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error)

MarshalToWriter marshals the data to an io.Writer.

func Unmarshal Uses

func Unmarshal(data []byte, v Unmarshaler) error

Unmarshal decodes the JSON in data into the object.

func UnmarshalFromReader Uses

func UnmarshalFromReader(r io.Reader, v Unmarshaler) error

UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object.

type Marshaler Uses

type Marshaler interface {
    MarshalEasyJSON(w *jwriter.Writer)

Marshaler is an easyjson-compatible marshaler interface.

type Optional Uses

type Optional interface {
    IsDefined() bool

Optional defines an undefined-test method for a type to integrate with 'omitempty' logic.

type RawMessage Uses

type RawMessage []byte

RawMessage is a raw piece of JSON (number, string, bool, object, array or null) that is extracted without parsing and output as is during marshaling.

func (*RawMessage) IsDefined Uses

func (v *RawMessage) IsDefined() bool

IsDefined is required for integration with omitempty easyjson logic.

func (*RawMessage) MarshalEasyJSON Uses

func (v *RawMessage) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON does JSON marshaling using easyjson interface.

func (RawMessage) MarshalJSON Uses

func (v RawMessage) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler interface.

func (*RawMessage) UnmarshalEasyJSON Uses

func (v *RawMessage) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.

func (*RawMessage) UnmarshalJSON Uses

func (v *RawMessage) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler interface.

type UnknownFieldsProxy Uses

type UnknownFieldsProxy struct {
    // contains filtered or unexported fields

UnknownFieldsProxy implemets UnknownsUnmarshaler and UnknownsMarshaler use it as embedded field in your structure to parse and then serialize unknown struct fields

func (UnknownFieldsProxy) MarshalUnknowns Uses

func (s UnknownFieldsProxy) MarshalUnknowns(out *jwriter.Writer, first bool)

func (*UnknownFieldsProxy) UnmarshalUnknown Uses

func (s *UnknownFieldsProxy) UnmarshalUnknown(in *jlexer.Lexer, key string)

type UnknownsMarshaler Uses

type UnknownsMarshaler interface {
    MarshalUnknowns(w *jwriter.Writer, first bool)

UnknownsMarshaler provides a method to write additional struct fields

type UnknownsUnmarshaler Uses

type UnknownsUnmarshaler interface {
    UnmarshalUnknown(in *jlexer.Lexer, key string)

UnknownsUnmarshaler provides a method to unmarshal unknown struct fileds and save them as you want

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalEasyJSON(w *jlexer.Lexer)

Marshaler is an easyjson-compatible unmarshaler interface.


benchmarkPackage benchmark provides a simple benchmark for easyjson against default serialization and ffjson.
bootstrapPackage bootstrap implements the bootstrapping logic: generation of a .go file to launch the actual generator and launching the generator itself.
bufferPackage buffer implements a buffer for serialization, consisting of a chain of []byte-s to reduce copying and to allow reuse of individual chunks.
jlexerPackage jlexer contains a JSON lexer implementation.
jwriterPackage jwriter contains a JSON writer.

Package easyjson imports 7 packages (graph) and is imported by 1233 packages. Updated 2020-05-24. Refresh now. Tools for package owners.