json

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: ISC Imports: 2 Imported by: 6

Documentation

Overview

Package json allows for different implementations of JSON serializing, as well as extra optional types needed.

Index

Constants

This section is empty.

Variables

View Source
var (
	True  = getBool(true)
	False = getBool(false)

	ZeroUint = Uint(0)
	ZeroInt  = Int(0)

	EmptyString = String("")
)

Functions

func DecodeStream added in v0.5.0

func DecodeStream(r io.Reader, v interface{}) error

DecodeStream uses the default driver.

func EncodeStream added in v0.5.0

func EncodeStream(w io.Writer, v interface{}) error

EncodeStream uses the default driver.

func Marshal added in v0.5.0

func Marshal(v interface{}) ([]byte, error)

Marshal uses the default driver.

func Unmarshal added in v0.5.0

func Unmarshal(data []byte, v interface{}) error

Unmarshal uses the default driver.

Types

type DefaultDriver added in v0.5.0

type DefaultDriver struct{}

func (DefaultDriver) DecodeStream added in v0.5.0

func (d DefaultDriver) DecodeStream(r io.Reader, v interface{}) error

func (DefaultDriver) EncodeStream added in v0.5.0

func (d DefaultDriver) EncodeStream(w io.Writer, v interface{}) error

func (DefaultDriver) Marshal added in v0.5.0

func (d DefaultDriver) Marshal(v interface{}) ([]byte, error)

func (DefaultDriver) Unmarshal added in v0.5.0

func (d DefaultDriver) Unmarshal(data []byte, v interface{}) error

type Driver

type Driver interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error

	DecodeStream(r io.Reader, v interface{}) error
	EncodeStream(w io.Writer, v interface{}) error
}
var Default Driver = DefaultDriver{}

Default is the default JSON driver, which uses encoding/json.

type OptionBool

type OptionBool = *bool

type OptionInt

type OptionInt = *int

func Int

func Int(i int) OptionInt

type OptionString

type OptionString = *string

func String

func String(s string) OptionString

type OptionUint

type OptionUint = *uint

func Uint

func Uint(u uint) OptionUint

type Raw

type Raw []byte

Raw is a raw encoded JSON value. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding. It's taken from encoding/json.

func (Raw) MarshalJSON

func (m Raw) MarshalJSON() ([]byte, error)

Raw returns m as the JSON encoding of m.

func (Raw) String

func (m Raw) String() string

func (*Raw) UnmarshalJSON

func (m *Raw) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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