easyjson

package module
v0.0.0-...-d7da6dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package easyjson contains marshaler/unmarshaler interfaces and helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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 MarshalCustom

func MarshalCustom(v Marshaler, usingTagName string) ([]byte, error)

func MarshalToHTTPResponseWriter

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 MarshalToHTTPResponseWriterCustom

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

func MarshalToWriter

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

MarshalToWriter marshals the data to an io.Writer.

func MarshalToWriterCustom

func MarshalToWriterCustom(v Marshaler, w io.Writer, usingTagName string) (written int, err error)

func Unmarshal

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

Unmarshal decodes the JSON in data into the object.

func UnmarshalCustom

func UnmarshalCustom(data []byte, v Unmarshaler, usingTagName string) error

func UnmarshalFromReader

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

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

func UnmarshalFromReaderCustom

func UnmarshalFromReaderCustom(r io.Reader, v Unmarshaler, usingTagName string) error

Types

type Marshaler

type Marshaler interface {
	MarshalEasyJSON(w *jwriter.Writer, usingTagName string)
}

Marshaler is an easyjson-compatible marshaler interface.

type Optional

type Optional interface {
	IsDefined() bool
}

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

type Unmarshaler

type Unmarshaler interface {
	UnmarshalEasyJSON(w *jlexer.Lexer, usingTagName string)
}

Marshaler is an easyjson-compatible unmarshaler interface.

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL