json

package
v0.0.0-...-0d40728 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Array

func Array(json map[string]interface{}, path ...string) ([]map[string]interface{}, bool)

Array returns an []map[string]interface{} property under the given key.

func Bool

func Bool(json map[string]interface{}, path ...string) (bool, bool)

Bool returns a bool property under the given key.

func BoolArray

func BoolArray(json map[string]interface{}, path ...string) ([]bool, bool)

BoolArray returns an []bool property under the given key.

func Copy

func Copy(j map[string]interface{}) (map[string]interface{}, error)

Copy will copy the JSON data deeply by value, this process involves marshalling and then unmarshalling the data.

func DoubleArray

func DoubleArray(json map[string]interface{}, path ...string) ([][]map[string]interface{}, bool)

DoubleArray returns an [][]map[string]interface{} property under the given key.

func Exists

func Exists(json map[string]interface{}, path ...string) bool

Exists returns true if something exists under the provided path.

func Float

func Float(json map[string]interface{}, path ...string) (float64, bool)

Float returns a float property under the given key.

func FloatArray

func FloatArray(json map[string]interface{}, path ...string) ([]float64, bool)

FloatArray returns a []float64 property under the given key.

func FloatDefault

func FloatDefault(json map[string]interface{}, def float64, path ...string) float64

FloatDefault returns a float property under the given key, if it doesn't exist, it will return the provided default.

func Get

func Get(json map[string]interface{}, path ...string) (map[string]interface{}, bool)

Get returns a map[string]interface{} under the given path.

func Int

func Int(json map[string]interface{}, path ...string) (int, bool)

Int returns an int property under the given key.

func IntArray

func IntArray(json map[string]interface{}, path ...string) ([]int, bool)

IntArray returns an []int64 property under the given key.

func IntDefault

func IntDefault(json map[string]interface{}, def int, path ...string) int

IntDefault returns an int property under the given key, if it doesn't exist, it will return the provided default.

func Interface

func Interface(json map[string]interface{}, path ...string) (interface{}, bool)

Interface returns an interface{} under the given path.

func InterfaceArray

func InterfaceArray(json map[string]interface{}, path ...string) ([]interface{}, bool)

InterfaceArray returns a []interface{} under the given path.

func Map

func Map(json map[string]interface{}, path ...string) (map[string]map[string]interface{}, bool)

Map returns a map[string]map[string]interface{} of all child nodes under the given path.

func MapToStruct

func MapToStruct(res interface{}, arg map[string]interface{}) error

MapToStruct converts a map[string]interface{} to its struct equivalent.

func Marshal

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

Marshal marhsals JSON into a byte slice, convenience wrapper for the native package so no need to import both and get a name collision.

func ReadFile

func ReadFile(file string) (map[string]interface{}, error)

ReadFile will read a json file into a byte array and unmarshal it to a map[string]interface

func String

func String(json map[string]interface{}, path ...string) (string, bool)

String returns a string property under the given path.

func StringArray

func StringArray(json map[string]interface{}, path ...string) ([]string, bool)

StringArray returns an []string property under the given key.

func StringDefault

func StringDefault(json map[string]interface{}, def string, path ...string) string

StringDefault returns a string property under the given key, if it doesn't exist, it will return the provided default.

func Struct

func Struct(j map[string]interface{}, arg interface{}, path ...string) bool

Struct fills a struct under the given path.

func StructToMap

func StructToMap(arg interface{}) map[string]interface{}

StructToMap converts a struct to its map[string]interface{} equivalent.

func Unmarshal

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

Unmarshal unmarshals JSON and returns a newly instantiated map.

Types

type RawMessage

type RawMessage json.RawMessage

RawMessage is an alias for json.RawMessage

Jump to

Keyboard shortcuts

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