zjson

package
Version: v0.0.0-...-6fe5ffd Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 5 Imported by: 3

Documentation

Overview

Package zjson provides functions for working with JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Indent

func Indent(data []byte, v interface{}, prefix, indent string) ([]byte, error)

Indent a json string by unmarshalling it and marshalling it with MarshalIndent.

The data will be unmarshalled in to v, which must be a pointer. Example:

Indent(`{"a": "b"}`, &map[string]string{}, "", "  ")

func MustIndent

func MustIndent(data []byte, v interface{}, prefix, indent string) []byte

MustIndent behaves like Indent but will panic on errors.

func MustMarshal

func MustMarshal(v interface{}) []byte

MustMarshal behaves like json.Marshal but will panic on errors.

func MustMarshalIndent

func MustMarshalIndent(v interface{}, prefix, indent string) []byte

MustMarshalIndent behaves like json.MarshalIndent but will panic on errors.

func MustUnmarshal

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

MustUnmarshal behaves like json.Unmarshal but will panic on errors.

Types

type Int

type Int int64

Int for APIs that return numbers as strings.

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

Marshal in to JSON.

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(v []byte) error

Unmarshal a string timestamp as an int.

type Timestamp

type Timestamp struct{ time.Time }

Timestamp for APIs that return dates as a numeric Unix timestamp.

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

Marshal in to JSON.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(v []byte) error

Unmarshal a Unix timestamp as a date.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL