jsonbuilder

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotMap    = errors.New("JEntry type is not map")
	ErrNotString = errors.New("JEntry type is not string")
	ErrNotArray  = errors.New("JEntry type is not array")
	ErrNotFound  = errors.New("not found")
)

Functions

This section is empty.

Types

type EntryType

type EntryType string
const (
	ETArray    EntryType = "array"
	ETMap      EntryType = "map"
	ETString   EntryType = "string"
	ETNumber   EntryType = "number"
	ETLeafList EntryType = "leaflist"
)

type JEntry

type JEntry struct {
	// contains filtered or unexported fields
}

func NewJEntryArray

func NewJEntryArray(name string) *JEntry

NewJEntryArray initializes as Array typed JEntry

func NewJEntryMap

func NewJEntryMap(name string) *JEntry

NewJEntryMap initializes as Map typed JEntry

func NewJEntryString

func NewJEntryString(s string) *JEntry

NewJEntryString initializes as String typed JEntry

func (*JEntry) AddToArray

func (j *JEntry) AddToArray(je ...*JEntry) error

AddArrayEntry adds the given JEntry to the Array returns an error if this JEntry is not of the type ETArray

func (*JEntry) AddToMap

func (j *JEntry) AddToMap(key string, je *JEntry) error

AddMapEntry adds the given JEntry to the Map returns an error if this JEntry is not of the type ETArray

func (*JEntry) AssureArray

func (j *JEntry) AssureArray() error

AssureArray returns an error if this JEntry is not of type ETArray

func (*JEntry) AssureMap

func (j *JEntry) AssureMap() error

AssureMap returns an error if this JEntry is not of type ETMap

func (*JEntry) AssureString

func (j *JEntry) AssureString() error

AssureString returns an error if this JEntry is not of type ETString

func (*JEntry) GetArray

func (j *JEntry) GetArray() []*JEntry

GetArray returns the Array value

func (*JEntry) GetMap

func (j *JEntry) GetMap() map[string]*JEntry

GetMap returns the Map vlaue

func (*JEntry) GetString

func (j *JEntry) GetString() string

GetString returns the String value

func (*JEntry) GetSubElem

func (j *JEntry) GetSubElem(name string, key map[string]string, create bool, nextKeys map[string]string, lastElem bool) (*JEntry, error)

func (*JEntry) GetSubElemMap

func (j *JEntry) GetSubElemMap(name string, key map[string]string, create bool, nextKeys map[string]string, lastElem bool) (*JEntry, error)

func (*JEntry) GetType

func (j *JEntry) GetType() EntryType

GetType returns the underlaying type of the JEntry

func (*JEntry) IsArray

func (j *JEntry) IsArray() bool

IsArray returns true if the JEntry is of type ETArray

func (*JEntry) IsMap

func (j *JEntry) IsMap() bool

IsMap returns true if the JEntry is of type ETMap

func (*JEntry) IsString

func (j *JEntry) IsString() bool

IsString returns true if the JEntry is of type ETString

func (*JEntry) MarshalJSON

func (j *JEntry) MarshalJSON() ([]byte, error)

MarshalJSON custom marshaller, that returns the JEntry in the correct form (Array, Map or String value)

func (*JEntry) String

func (j *JEntry) String() string

type JsonBuilder

type JsonBuilder struct {
	// contains filtered or unexported fields
}

func NewJsonBuilder

func NewJsonBuilder() *JsonBuilder

func (*JsonBuilder) AddValue

func (jb *JsonBuilder) AddValue(p []*sdcpb.PathElem, v string) error

func (*JsonBuilder) GetDoc

func (jb *JsonBuilder) GetDoc() ([]byte, error)

func (*JsonBuilder) GetDocIndent

func (jb *JsonBuilder) GetDocIndent() ([]byte, error)

Jump to

Keyboard shortcuts

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