joe

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package joe provides helper types and methods for encoding and decoding JSON.

joe provides a simple API to access unstructured and ad hoc JSON objects that is parsed generically by json.Unmarshal. When a inputs are unstructured, it can be difficult to define Go structs that map cleanly onto the JSON input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array []Interface

func (Array) Bool

func (Array) Bool() (bool, error)

func (Array) Get

func (Array) Get(field string) (Interface, error)

func (Array) Index

func (a Array) Index(k int) (Interface, error)

func (Array) Number

func (Array) Number() (float64, error)

func (Array) String

func (Array) String() (string, error)

type Bool

type Bool bool

func (Bool) Bool

func (b Bool) Bool() (bool, error)

func (Bool) Get

func (Bool) Get(field string) (Interface, error)

func (Bool) Index

func (Bool) Index(k int) (Interface, error)

func (Bool) Number

func (Bool) Number() (float64, error)

func (Bool) String

func (Bool) String() (string, error)

type Interface

type Interface interface {
	Get(string) (Interface, error)
	Index(int) (Interface, error)
	Number() (float64, error)
	String() (string, error)
	Bool() (bool, error)
}

func Convert

func Convert(v interface{}) Interface

func Unmarshal

func Unmarshal(in []byte) (Interface, error)

type Number

type Number float64

func (Number) Bool

func (Number) Bool() (bool, error)

func (Number) Get

func (Number) Get(field string) (Interface, error)

func (Number) Index

func (Number) Index(k int) (Interface, error)

func (Number) Number

func (n Number) Number() (float64, error)

func (Number) String

func (Number) String() (string, error)

type Object

type Object map[string]Interface

func NewObject

func NewObject() Object

func (Object) Bool

func (Object) Bool() (bool, error)

func (Object) Get

func (o Object) Get(field string) (Interface, error)

func (Object) GetArray

func (o Object) GetArray(field string) (Array, error)

func (Object) GetBool

func (o Object) GetBool(field string) (bool, error)

func (Object) GetNumber

func (o Object) GetNumber(field string) (float64, error)

func (Object) GetObject

func (o Object) GetObject(field string) (Object, error)

func (Object) GetString

func (o Object) GetString(field string) (string, error)

func (Object) Index

func (Object) Index(k int) (Interface, error)

func (Object) Number

func (Object) Number() (float64, error)

func (Object) String

func (Object) String() (string, error)

func (*Object) UnmarshalJSON

func (o *Object) UnmarshalJSON(b []byte) error

type String

type String string

func (String) Bool

func (String) Bool() (bool, error)

func (String) Get

func (String) Get(field string) (Interface, error)

func (String) Index

func (String) Index(k int) (Interface, error)

func (String) Number

func (String) Number() (float64, error)

func (String) String

func (s String) String() (string, error)

Jump to

Keyboard shortcuts

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