json

package
v0.0.0-...-ff6bfbe Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotMap = errors.New("cannot unmarshal into Map, not a json object")

ErrNotMap is returned when Map.UnmarshalJSON is called with bytes not representing null or a json object.

Functions

This section is empty.

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is a time.Duration with JSON unmarshaling that uses time.ParseDuration.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON fulfills the encoding/json.Unmarshaler interface. It attempts to parse text as a time.Duration string. The Go documentation defines this as a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"). If there is no time unit, UnmarshalJSON defaults to ms.

type HexBytes

type HexBytes []byte

HexBytes is a byte slice with hex encoding and decoding when marshaled and unmarshaled.

func (HexBytes) MarshalText

func (h HexBytes) MarshalText() ([]byte, error)

MarshalText satisfies the encoding.TextMarshaler interface.

func (*HexBytes) UnmarshalText

func (h *HexBytes) UnmarshalText(text []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface

type Map

type Map []byte

Map is a byte slice that should parse as a string encoding a JSON object. This is checked in UnmarshalJSON.

func (Map) MarshalJSON

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

MarshalJSON satisfies the json.Marshaler interface.

func (*Map) UnmarshalJSON

func (m *Map) UnmarshalJSON(text []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Value

type Value int
const (
	Unknown Value = iota
	String
	Number
	Object
	Array
	True
	False
	Null
)

func ValueType

func ValueType(data []byte) (Value, error)

Jump to

Keyboard shortcuts

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