encoding

package
v3.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2017 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package encoding provides encoding features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSONArray

func MarshalJSONArray(callback func() (interface{}, error, bool)) ([]byte, error)

MarshalJSONArray marshals a JSON array from values returned by the given function.

The given function returns the value, error, and a boolean telling whether a new value is present.

If the error is not nil, it stops marshalling and calls the function as long as it says a new value is present. That behavior is convenient to marshal channels, which are often needed to be drained to release resources.

func MarshalJSONObject

func MarshalJSONObject(callback func() (string, interface{}, error, bool)) ([]byte, error)

MarshalJSONObject marshals a JSON object from values returned by the given function.

The given function returns the key, value, error, and a boolean telling whether a new value is present.

If the error is not nil, it stops marshalling and calls the function as long as it says a new value is present. That behavior is convenient to marshal channels, which are often needed to be drained to release resources.

Types

type Time

type Time struct {
	jwt.Time
}

Time is a type representing a time and marshallable as JSON.

func NewTime

func NewTime(unwrapped time.Time) Time

func ParseQueryTime

func ParseQueryTime(encoded string) (Time, error)

ParseQueryTime parses time in URL query.

func (Time) Generic

func (specific Time) Generic() time.Time

type ZeroString

type ZeroString string

ZeroString is a string which should be marshalled as null if it has zero value.

func (ZeroString) MarshalJSON

func (zeroString ZeroString) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the value.

This implements an interface used in encoding/encoding.

json - The Go Programming Language Example (CustomMarshalJSON) https://golang.org/pkg/encoding/json/#example__customMarshalJSON

type ZeroUint16

type ZeroUint16 uint16

ZeroUint16 is a uint16 which should be marshalled as null if it has zero value.

func (ZeroUint16) MarshalJSON

func (zeroUint16 ZeroUint16) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the value.

This implements an interface used in encoding/encoding.

json - The Go Programming Language Example (CustomMarshalJSON) https://golang.org/pkg/encoding/json/#example__customMarshalJSON

Jump to

Keyboard shortcuts

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