cbjson

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

Marshal marshal v into valid JSON

func MarshalIndent

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

MarshalIndent is like Marshal but applies Indent to format the output

func NewDecoder

func NewDecoder(r io.Reader) *jsoniter.Decoder

NewDecoder create decoder read from an input stream

func NewEncoder

func NewEncoder(w io.Writer) *jsoniter.Encoder

func ToJsonString

func ToJsonString(obj interface{}) string

func Unmarshal

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

Unmarshal unmarshal a JSON data to v

Types

type ContentBuilder

type ContentBuilder interface {
	Field(name string) ContentBuilder
	ValueString(value string) ContentBuilder
	ValueNumeric(value int64) ContentBuilder
	ValueUNumeric(value uint64) ContentBuilder
	ValueFloat(value float64) ContentBuilder
	ValueBool(value bool) ContentBuilder
	ValueNull() ContentBuilder
	ValueInterface(value interface{}) ContentBuilder
	ValueRaw(raw string) ContentBuilder

	BeginObject() ContentBuilder
	BeginObjectWithField(name string) ContentBuilder
	EndObject() ContentBuilder

	BeginArray() ContentBuilder
	BeginArrayWithField(name string) ContentBuilder
	EndArray() ContentBuilder

	More() ContentBuilder
	Output() ([]byte, error)
}

func ContentBuilderFactory

func ContentBuilderFactory() ContentBuilder

type JsonArr

type JsonArr []interface{}

type JsonArrMap

type JsonArrMap []JsonMap

type JsonContentBuilder

type JsonContentBuilder struct {
	*jsoniter.Stream
}

func (*JsonContentBuilder) BeginArray

func (b *JsonContentBuilder) BeginArray() ContentBuilder

func (*JsonContentBuilder) BeginArrayWithField

func (b *JsonContentBuilder) BeginArrayWithField(name string) ContentBuilder

func (*JsonContentBuilder) BeginObject

func (b *JsonContentBuilder) BeginObject() ContentBuilder

func (*JsonContentBuilder) BeginObjectWithField

func (b *JsonContentBuilder) BeginObjectWithField(name string) ContentBuilder

func (*JsonContentBuilder) EndArray

func (b *JsonContentBuilder) EndArray() ContentBuilder

func (*JsonContentBuilder) EndObject

func (b *JsonContentBuilder) EndObject() ContentBuilder

func (*JsonContentBuilder) Field

func (b *JsonContentBuilder) Field(name string) ContentBuilder

func (*JsonContentBuilder) More

func (*JsonContentBuilder) Output

func (b *JsonContentBuilder) Output() ([]byte, error)

func (*JsonContentBuilder) ValueBool

func (b *JsonContentBuilder) ValueBool(value bool) ContentBuilder

func (*JsonContentBuilder) ValueFloat

func (b *JsonContentBuilder) ValueFloat(value float64) ContentBuilder

func (*JsonContentBuilder) ValueInterface

func (b *JsonContentBuilder) ValueInterface(value interface{}) ContentBuilder

func (*JsonContentBuilder) ValueNull

func (b *JsonContentBuilder) ValueNull() ContentBuilder

func (*JsonContentBuilder) ValueNumeric

func (b *JsonContentBuilder) ValueNumeric(value int64) ContentBuilder

func (*JsonContentBuilder) ValueRaw

func (b *JsonContentBuilder) ValueRaw(raw string) ContentBuilder

func (*JsonContentBuilder) ValueString

func (b *JsonContentBuilder) ValueString(value string) ContentBuilder

func (*JsonContentBuilder) ValueUNumeric

func (b *JsonContentBuilder) ValueUNumeric(value uint64) ContentBuilder

type JsonMap

type JsonMap map[string]interface{}

func ByteToJsonMap

func ByteToJsonMap(bytes []byte) (JsonMap, error)

func (JsonMap) GetJsonArr

func (this JsonMap) GetJsonArr(key string) JsonArr

func (JsonMap) GetJsonArrMap

func (this JsonMap) GetJsonArrMap(key string) JsonArrMap

func (JsonMap) GetJsonMap

func (this JsonMap) GetJsonMap(key string) JsonMap

func (JsonMap) GetJsonVal

func (this JsonMap) GetJsonVal(key string) JsonVal

func (JsonMap) GetJsonValBool

func (this JsonMap) GetJsonValBool(key string) bool

func (JsonMap) GetJsonValBoolE

func (this JsonMap) GetJsonValBoolE(key string) (bool, error)

func (JsonMap) GetJsonValBytes

func (this JsonMap) GetJsonValBytes(key string) ([]byte, error)

func (JsonMap) GetJsonValIntE

func (this JsonMap) GetJsonValIntE(key string) (int, error)

func (JsonMap) GetJsonValString

func (this JsonMap) GetJsonValString(key string) string

func (JsonMap) GetJsonValStringE

func (this JsonMap) GetJsonValStringE(key string) (string, error)

func (JsonMap) GetJsonValStringOrDefault

func (this JsonMap) GetJsonValStringOrDefault(key, def string) string

type JsonVal

type JsonVal interface{}

Jump to

Keyboard shortcuts

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