go.jsonvalue: github.com/Andrew-M-C/go.jsonvalue Index | Examples | Files

package jsonvalue

import "github.com/Andrew-M-C/go.jsonvalue"

Package jsonvalue is for JSON parsing and setting. It is used in situations those Go structures cannot achieve, or "map[string]interface{}" could not do properbally.

As a quick start:

v := jsonvalue.NewObject()
v.SetString("Hello, JSON").At("someObject", "someObject", "someObject", "message")  // automatically create sub objects
fmt.Println(v.MustMarshalString())                                                  // marshal to string type
// Output:
// {"someObject":{"someObject":{"someObject":{"message":"Hello, JSON!"}}}

If you want to parse raw JSON data, use Unmarshal()

raw := []byte(`{"message":"hello, world"}`)
v, err := jsonvalue.Unmarshal(raw)
s, _ := v.GetString("message")
fmt.Println(s)
// Output:
// hello, world

Index

Examples

Package Files

append.go conv.go delete.go doc.go errors.go get.go insert.go jsonvalue.go marshal.go new.go set.go

Constants

const (
    // ErrNilParameter identifies input paremeter is nil
    ErrNilParameter = Error("nil parameter")
    // ErrValueUninitialized identifies that a V object is not initialized
    ErrValueUninitialized = Error("jsonvalue instance is not initialized")
    // ErrRawBytesUnrecignized identifies all unexpected raw bytes
    ErrRawBytesUnrecignized = Error("unrecognized raw text")
    // ErrNotValidBoolValue shows that a value starts with 't' or 'f' is not eventually a bool value
    ErrNotValidBoolValue = Error("not a valid bool object")
    // ErrNotValidNulllValue shows that a value starts with 'n' is not eventually a bool value
    ErrNotValidNulllValue = Error("not a valid null object")
    // ErrOutOfRange identifies that given position for a JSON array is out of range
    ErrOutOfRange = Error("out of range")
    // ErrNotFound shows that given target is not found in Delete()
    ErrNotFound = Error("target not found")
    // ErrTypeNotMatch shows that value type is not same as GetXxx()
    ErrTypeNotMatch = Error("not match given type")
    // ErrNotArrayValue shows that operation target value is not an array
    ErrNotArrayValue = Error("not an array typed value")
)

type Append Uses

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

Append type is for InTheEnd() or InTheBeginning() function. Please refer to related functions.

Shoud ONLY be generated by V.Append() function

func (*Append) InTheBeginning Uses

func (apd *Append) InTheBeginning(params ...interface{}) (*V, error)

InTheBeginning completes the following operation of Append().

Code:

s := `{"obj":{"arr":[1,2,3,4,5]}}`
v, _ := jsonvalue.UnmarshalString(s)

// append a zero in the bebinning of v.obj.arr
v.AppendInt(0).InTheBeginning("obj", "arr")
s = v.MustMarshalString()

fmt.Println(s)

Output:

{"obj":{"arr":[0,1,2,3,4,5]}}

func (*Append) InTheEnd Uses

func (apd *Append) InTheEnd(params ...interface{}) (*V, error)

InTheEnd completes the following operation of Append().

Code:

s := `{"obj":{"arr":[1,2,3,4,5]}}`
v, _ := jsonvalue.UnmarshalString(s)

// append a zero in the end of v.obj.arr
v.AppendInt(0).InTheEnd("obj", "arr")
s = v.MustMarshalString()

fmt.Println(s)

Output:

{"obj":{"arr":[1,2,3,4,5,0]}}

type Error Uses

type Error string

Error is equavilent to string and used to create some error constants in this package. Error constants: http://godoc.org/github.com/Andrew-M-C/go.jsonvalue/#pkg-constants

func (Error) Error Uses

func (e Error) Error() string

type Insert Uses

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

Insert type is for After() and Before() function. Please refer for realated function.

Should be generated ONLY BY V.Insert function!

func (*Insert) After Uses

func (ins *Insert) After(firstParam interface{}, otherParams ...interface{}) (*V, error)

After completes the following operation of Insert().

The last parameter identifies the postion where a new JSON is inserted after, it should ba an interger, no matter signed or unsigned. If the position is zero or positive interger, it tells the index of an array. If the position is negative, it tells the backward index of an array.

For example, 0 represents the first, and -2 represents the second last.

Code:

s := `{"obj":{"arr":["hello","world"]}}`
v, _ := jsonvalue.UnmarshalString(s)

// insert a word in the middle, which is after the first word of the array
v.InsertString("my").After("obj", "arr", 0)

fmt.Println(v.MustMarshalString())

Output:

{"obj":{"arr":["hello","my","world"]}}

func (*Insert) Before Uses

func (ins *Insert) Before(firstParam interface{}, otherParams ...interface{}) (*V, error)

Before completes the following operation of Insert().

The last parameter identifies the postion where a new JSON is inserted after, it should ba an interger, no matter signed or unsigned. If the position is zero or positive interger, it tells the index of an array. If the position is negative, it tells the backward index of an array.

For example, 0 represents the first, and -2 represents the second last.

Code:

s := `{"obj":{"arr":["hello","world"]}}`
v, _ := jsonvalue.UnmarshalString(s)

// insert a word in the middle, which is before the second word of the array
v.InsertString("my").Before("obj", "arr", 1)

fmt.Println(v.MustMarshalString())

Output:

{"obj":{"arr":["hello","my","world"]}}

type Opt Uses

type Opt struct {
    // OmitNull tells how to handle null json value. The default value is false.
    // If OmitNull is true, null value will be omitted whan marshaling.
    OmitNull bool
}

Opt is the option of jsonvalue.

Code:

raw := `{"null":null}`
v, _ := jsonvalue.UnmarshalString(raw)

s := v.MustMarshalString()
fmt.Println(s)
s = v.MustMarshalString(jsonvalue.Opt{OmitNull: true})
fmt.Println(s)

Output:

{"null":null}
{}

type Set Uses

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

Set type is for At() only. Please refer to At() function.

This should be generated by V.Set functions ONLY.

func (*Set) At Uses

func (s *Set) At(firstParam interface{}, otherParams ...interface{}) (*V, error)

At completes the following operation of Set(). It defines posttion of value in Set() and return the new value set.

The usage of At() is perhaps the most important. This function will recursivly search for child value, and set the new value specified by Set() or SetXxx() series functions. Please unfold and read the following examples, they are important.

For a simplest example:

Code:

v := jsonvalue.NewObject()                        // {}
v.SetObject().At("obj")                           // {"obj":{}}
v.SetString("Hello, world!").At("obj", "message") // {"obj":{"message":"Hello, world!"}}
fmt.Println(v.MustMarshalString())

Output:

{"obj":{"message":"Hello, world!"}}

Or you can make it even more simpler, as At() function will automatically create objects those do not exist

Code:

v := jsonvalue.NewObject()                        // {}
v.SetString("Hello, world!").At("obj", "message") // {"obj":{"message":"Hello, world!"}}
fmt.Println(v.MustMarshalString())

Output:

{"obj":{"message":"Hello, world!"}}

As for array, At() also works

Code:

v := jsonvalue.NewObject()                // {}
v.SetString("Hello, world!").At("arr", 0) // {"arr":[Hello, world!]}
fmt.Println(v.MustMarshalString())

Output:

{"arr":["Hello, world!"]}

Auto-array-creating in At() function is actually a bit complicated. It fails when specifying an position that the array does not have yet. But with one exception: the index value is equal to the length of an array, in this case, a new value will be append to the end of the array. This is quite convient when setting array elements in a for-range block.

Code:

v := jsonvalue.NewObject()                         // {}
_, err := v.SetString("Hello, world").At("arr", 1) // failed because there are no children of v.arr
if err != nil {
    fmt.Println("got error:", err)
}

fmt.Println(v.MustMarshalString()) // as error occurred, the "arr" array would not be set

integers := []int{10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
for i, n := range integers {
    // this will succeed because i is equal to len(v.arr) every time
    v.SetInt(n).At("arr", i)
}

fmt.Println(v.MustMarshalString())

Output:

got error: out of range
{}
{"arr":[10,20,30,40,50,60,70,80,90,100]}

As for elements those in positions that the array already has, At() will REPLACE it.

Code:

v := jsonvalue.NewObject()
for i := 0; i < 10; i++ {
    v.SetInt(i).At("arr", i)
}

fmt.Println(v.MustMarshalString())

v.SetFloat64(123.12345, -1).At("arr", 3)
fmt.Println(v.MustMarshalString())

Output:

{"arr":[0,1,2,3,4,5,6,7,8,9]}
{"arr":[0,1,2,123.12345,4,5,6,7,8,9]}

type V Uses

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

V is the main type of jsonvalue, representing a JSON value.

func NewArray Uses

func NewArray() *V

NewArray returns an emty array-typed jsonvalue object

func NewBool Uses

func NewBool(b bool) *V

NewBool returns an initialied boolean jsonvalue object

func NewFloat32 Uses

func NewFloat32(f float32, prec int) *V

NewFloat32 returns an initialied num jsonvalue object by float32 type. The precision prec controls the number of digits. Use -1 in prec for automatically precision.

func NewFloat64 Uses

func NewFloat64(f float64, prec int) *V

NewFloat64 returns an initialied num jsonvalue object by float64 type. The precision prec controls the number of digits. Use -1 in prec for automatically precision.

Code:

f := 123.123456789
var v *jsonvalue.V

v = jsonvalue.NewFloat64(f, 9)
fmt.Println(v)

v = jsonvalue.NewFloat64(f, 6)
fmt.Println(v)

v = jsonvalue.NewFloat64(f, 10)
fmt.Println(v)

Output:

123.123456789
123.123457
123.1234567890

func NewInt Uses

func NewInt(i int) *V

NewInt returns an initialied num jsonvalue object by int type

func NewInt32 Uses

func NewInt32(i int32) *V

NewInt32 returns an initialied num jsonvalue object by int32 type

func NewInt64 Uses

func NewInt64(i int64) *V

NewInt64 returns an initialied num jsonvalue object by int64 type

func NewNull Uses

func NewNull() *V

NewNull returns an initialied null jsonvalue object

func NewObject Uses

func NewObject() *V

NewObject returns an empty object-typed jsonvalue object

func NewString Uses

func NewString(s string) *V

NewString returns an initialied string jsonvalue object

func NewUint Uses

func NewUint(u uint) *V

NewUint returns an initialied num jsonvalue object by uint type

func NewUint32 Uses

func NewUint32(u uint32) *V

NewUint32 returns an initialied num jsonvalue object by uint32 type

func NewUint64 Uses

func NewUint64(u uint64) *V

NewUint64 returns an initialied num jsonvalue object by uint64 type

func Unmarshal Uses

func Unmarshal(b []byte) (ret *V, err error)

Unmarshal parse raw bytes(encoded in UTF-8 or pure AscII) and returns a *V instance.

func UnmarshalString Uses

func UnmarshalString(s string) (*V, error)

UnmarshalString is equavilent to Unmarshal(string(b))

func (*V) Append Uses

func (v *V) Append(child *V) *Append

Append starts appending a child JSON value to a JSON array.

func (*V) AppendArray Uses

func (v *V) AppendArray() *Append

AppendArray is equivalent to Append(jsonvalue.NewArray())

func (*V) AppendBool Uses

func (v *V) AppendBool(b bool) *Append

AppendBool is equivalent to Append(jsonvalue.NewBool(b))

func (*V) AppendFloat32 Uses

func (v *V) AppendFloat32(f float32, prec int) *Append

AppendFloat32 is equivalent to Append(jsonvalue.NewFloat32(b))

func (*V) AppendFloat64 Uses

func (v *V) AppendFloat64(f float64, prec int) *Append

AppendFloat64 is equivalent to Append(jsonvalue.NewFloat64(b))

func (*V) AppendInt Uses

func (v *V) AppendInt(i int) *Append

AppendInt is equivalent to Append(jsonvalue.NewInt(b))

func (*V) AppendInt32 Uses

func (v *V) AppendInt32(i int32) *Append

AppendInt32 is equivalent to Append(jsonvalue.NewInt32(b))

func (*V) AppendInt64 Uses

func (v *V) AppendInt64(i int64) *Append

AppendInt64 is equivalent to Append(jsonvalue.NewInt64(b))

func (*V) AppendNull Uses

func (v *V) AppendNull() *Append

AppendNull is equivalent to Append(jsonvalue.NewNull())

func (*V) AppendObject Uses

func (v *V) AppendObject() *Append

AppendObject is equivalent to Append(jsonvalue.NewObject())

func (*V) AppendString Uses

func (v *V) AppendString(s string) *Append

AppendString is equivalent to Append(jsonvalue.NewString(s))

func (*V) AppendUint Uses

func (v *V) AppendUint(u uint) *Append

AppendUint is equivalent to Append(jsonvalue.NewUint(b))

func (*V) AppendUint32 Uses

func (v *V) AppendUint32(u uint32) *Append

AppendUint32 is equivalent to Append(jsonvalue.NewUint32(b))

func (*V) AppendUint64 Uses

func (v *V) AppendUint64(u uint64) *Append

AppendUint64 is equivalent to Append(jsonvalue.NewUint64(b))

func (*V) Bool Uses

func (v *V) Bool() bool

Bool returns represented bool value. If value is not boolean, returns false.

func (*V) Delete Uses

func (v *V) Delete(firstParam interface{}, otherParams ...interface{}) error

Delete deletes specified JSON value

func (*V) Float32 Uses

func (v *V) Float32() float32

Float32 returns represented float32 value. If value is not a number, returns zero.

func (*V) Float64 Uses

func (v *V) Float64() float64

Float64 returns represented float64 value. If value is not a number, returns zero.

func (*V) Get Uses

func (v *V) Get(firstParam interface{}, otherParams ...interface{}) (*V, error)

Get returns JSON value in specified position. Param formats are like At()

Code:

s := `{"objA":{"objB":{"message":"Hello, world!"}}}`
v, _ := jsonvalue.UnmarshalString(s)
msg, _ := v.Get("objA", "objB", "message")
fmt.Println(msg.String())

Output:

Hello, world!

func (*V) GetArray Uses

func (v *V) GetArray(firstParam interface{}, otherParams ...interface{}) (*V, error)

GetArray is equalivent to v, err := Get(...); raise err if v.IsArray() == false

func (*V) GetBool Uses

func (v *V) GetBool(firstParam interface{}, otherParams ...interface{}) (bool, error)

GetBool is equalivent to v, err := Get(...); v.Bool()

func (*V) GetFloat32 Uses

func (v *V) GetFloat32(firstParam interface{}, otherParams ...interface{}) (float32, error)

GetFloat32 is equalivent to v, err := Get(...); v.Int()

func (*V) GetFloat64 Uses

func (v *V) GetFloat64(firstParam interface{}, otherParams ...interface{}) (float64, error)

GetFloat64 is equalivent to v, err := Get(...); v.Int()

func (*V) GetInt Uses

func (v *V) GetInt(firstParam interface{}, otherParams ...interface{}) (int, error)

GetInt is equalivent to v, err := Get(...); v.Int()

func (*V) GetInt32 Uses

func (v *V) GetInt32(firstParam interface{}, otherParams ...interface{}) (int32, error)

GetInt32 is equalivent to v, err := Get(...); v.Int()

func (*V) GetInt64 Uses

func (v *V) GetInt64(firstParam interface{}, otherParams ...interface{}) (int64, error)

GetInt64 is equalivent to v, err := Get(...); v.Int()

func (*V) GetNull Uses

func (v *V) GetNull(firstParam interface{}, otherParams ...interface{}) error

GetNull is equalivent to v, err := Get(...); raise err if v.IsNull() == false

func (*V) GetObject Uses

func (v *V) GetObject(firstParam interface{}, otherParams ...interface{}) (*V, error)

GetObject is equalivent to v, err := Get(...); raise err if v.IsObject() == false

func (*V) GetString Uses

func (v *V) GetString(firstParam interface{}, otherParams ...interface{}) (string, error)

GetString is equalivent to v, err := Get(...); v.String()

func (*V) GetUint Uses

func (v *V) GetUint(firstParam interface{}, otherParams ...interface{}) (uint, error)

GetUint is equalivent to v, err := Get(...); v.Int()

func (*V) GetUint32 Uses

func (v *V) GetUint32(firstParam interface{}, otherParams ...interface{}) (uint32, error)

GetUint32 is equalivent to v, err := Get(...); v.Int()

func (*V) GetUint64 Uses

func (v *V) GetUint64(firstParam interface{}, otherParams ...interface{}) (uint64, error)

GetUint64 is equalivent to v, err := Get(...); v.Int()

func (*V) GreaterThanInt64Max Uses

func (v *V) GreaterThanInt64Max() bool

GreaterThanInt64Max return true when ALL conditions below are met:

1. It is a number value.
2. It is a positive interger.
3. Its value is greater than 0x7fffffffffffffff.

Code:

v1 := jsonvalue.NewUint64(uint64(9223372036854775808)) // 0x8000000000000000
v2 := jsonvalue.NewUint64(uint64(9223372036854775807)) // 0x7FFFFFFFFFFFFFFF
v3 := jsonvalue.NewInt64(int64(-9223372036854775807))
fmt.Println(v1.GreaterThanInt64Max())
fmt.Println(v2.GreaterThanInt64Max())
fmt.Println(v3.GreaterThanInt64Max())

Output:

true
false
false

func (*V) Insert Uses

func (v *V) Insert(child *V) *Insert

Insert starts setting a child JSON value

func (*V) InsertArray Uses

func (v *V) InsertArray() *Insert

InsertArray is equivalent to Insert(jsonvalue.NewArray())

func (*V) InsertBool Uses

func (v *V) InsertBool(b bool) *Insert

InsertBool is equivalent to Insert(jsonvalue.NewBool(b))

func (*V) InsertFloat32 Uses

func (v *V) InsertFloat32(f float32, prec int) *Insert

InsertFloat32 is equivalent to Insert(jsonvalue.NewFloat32(b))

func (*V) InsertFloat64 Uses

func (v *V) InsertFloat64(f float64, prec int) *Insert

InsertFloat64 is equivalent to Insert(jsonvalue.NewFloat64(b))

func (*V) InsertInt Uses

func (v *V) InsertInt(i int) *Insert

InsertInt is equivalent to Insert(jsonvalue.NewInt(b))

func (*V) InsertInt32 Uses

func (v *V) InsertInt32(i int32) *Insert

InsertInt32 is equivalent to Insert(jsonvalue.NewInt32(b))

func (*V) InsertInt64 Uses

func (v *V) InsertInt64(i int64) *Insert

InsertInt64 is equivalent to Insert(jsonvalue.NewInt64(b))

func (*V) InsertNull Uses

func (v *V) InsertNull() *Insert

InsertNull is equivalent to Insert(jsonvalue.NewNull())

func (*V) InsertObject Uses

func (v *V) InsertObject() *Insert

InsertObject is equivalent to Insert(jsonvalue.NewObject())

func (*V) InsertString Uses

func (v *V) InsertString(s string) *Insert

InsertString is equivalent to Insert(jsonvalue.NewString(s))

func (*V) InsertUint Uses

func (v *V) InsertUint(u uint) *Insert

InsertUint is equivalent to Insert(jsonvalue.NewUint(b))

func (*V) InsertUint32 Uses

func (v *V) InsertUint32(u uint32) *Insert

InsertUint32 is equivalent to Insert(jsonvalue.NewUint32(b))

func (*V) InsertUint64 Uses

func (v *V) InsertUint64(u uint64) *Insert

InsertUint64 is equivalent to Insert(jsonvalue.NewUint64(b))

func (*V) Int Uses

func (v *V) Int() int

Int returns represented int value. If value is not a number, returns zero.

func (*V) Int32 Uses

func (v *V) Int32() int32

Int32 returns represented int32 value. If value is not a number, returns zero.

func (*V) Int64 Uses

func (v *V) Int64() int64

Int64 returns represented int64 value. If value is not a number, returns zero.

func (*V) IsArray Uses

func (v *V) IsArray() bool

IsArray tells whether value is an array

func (*V) IsBoolean Uses

func (v *V) IsBoolean() bool

IsBoolean tells whether value is a boolean

func (*V) IsFloat Uses

func (v *V) IsFloat() bool

IsFloat tells whether value is a float point number

func (*V) IsInteger Uses

func (v *V) IsInteger() bool

IsInteger tells whether value is a fix point interger

func (*V) IsNegative Uses

func (v *V) IsNegative() bool

IsNegative tells whether value is a negative number

func (*V) IsNull Uses

func (v *V) IsNull() bool

IsNull tells whether value is a null

func (*V) IsNumber Uses

func (v *V) IsNumber() bool

IsNumber tells whether value is a number

func (*V) IsObject Uses

func (v *V) IsObject() bool

IsObject tells whether value is an object

func (*V) IsPositive Uses

func (v *V) IsPositive() bool

IsPositive tells whether value is a positive number

func (*V) IsString Uses

func (v *V) IsString() bool

IsString tells whether value is a string

func (*V) Len Uses

func (v *V) Len() int

Len returns length of an object or array type JSON value

func (*V) Marshal Uses

func (v *V) Marshal(opt ...Opt) (b []byte, err error)

Marshal returns marshaled bytes

func (*V) MarshalString Uses

func (v *V) MarshalString(opt ...Opt) (s string, err error)

MarshalString is same with Marshal, but returns string

func (*V) MustMarshal Uses

func (v *V) MustMarshal(opt ...Opt) []byte

MustMarshal is the same as Marshal, but panics if error pccurred

func (*V) MustMarshalString Uses

func (v *V) MustMarshalString(opt ...Opt) string

MustMarshalString is the same as MarshalString, but panics if error pccurred

func (*V) RangeArray Uses

func (v *V) RangeArray(callback func(i int, v *V) bool)

RangeArray goes through each children when this is an array value

Return true in callback to continue range iteration, while false to break.

Code:

s := `[1,2,3,4,5,6,7,8,9,10]`
v, _ := jsonvalue.UnmarshalString(s)

v.RangeArray(func(i int, v *jsonvalue.V) bool {
    fmt.Println(v)
    return i < 5
})

Output:

1
2
3
4
5
6

func (*V) RangeObjects Uses

func (v *V) RangeObjects(callback func(k string, v *V) bool)

RangeObjects goes through each children when this is an object value

Return true in callback to continue range iteration, while false to break.

func (*V) Set Uses

func (v *V) Set(child *V) *Set

Set starts setting a child JSON value. Please refer to examples of "func (set *Set) At(...)"

https://godoc.org/github.com/Andrew-M-C/go.jsonvalue/#Set.At

func (*V) SetArray Uses

func (v *V) SetArray() *Set

SetArray is equivalent to Set(jsonvalue.NewArray())

func (*V) SetBool Uses

func (v *V) SetBool(b bool) *Set

SetBool is equivalent to Set(jsonvalue.NewBool(b))

func (*V) SetFloat32 Uses

func (v *V) SetFloat32(f float32, prec int) *Set

SetFloat32 is equivalent to Set(jsonvalue.NewFloat32(b))

func (*V) SetFloat64 Uses

func (v *V) SetFloat64(f float64, prec int) *Set

SetFloat64 is equivalent to Set(jsonvalue.NewFloat64(b))

func (*V) SetInt Uses

func (v *V) SetInt(i int) *Set

SetInt is equivalent to Set(jsonvalue.NewInt(b))

func (*V) SetInt32 Uses

func (v *V) SetInt32(i int32) *Set

SetInt32 is equivalent to Set(jsonvalue.NewInt32(b))

func (*V) SetInt64 Uses

func (v *V) SetInt64(i int64) *Set

SetInt64 is equivalent to Set(jsonvalue.NewInt64(b))

func (*V) SetNull Uses

func (v *V) SetNull() *Set

SetNull is equivalent to Set(jsonvalue.NewNull())

func (*V) SetObject Uses

func (v *V) SetObject() *Set

SetObject is equivalent to Set(jsonvalue.NewObject())

func (*V) SetString Uses

func (v *V) SetString(s string) *Set

SetString is equivalent to Set(jsonvalue.NewString(s))

func (*V) SetUint Uses

func (v *V) SetUint(u uint) *Set

SetUint is equivalent to Set(jsonvalue.NewUint(b))

func (*V) SetUint32 Uses

func (v *V) SetUint32(u uint32) *Set

SetUint32 is equivalent to Set(jsonvalue.NewUint32(b))

func (*V) SetUint64 Uses

func (v *V) SetUint64(u uint64) *Set

SetUint64 is equivalent to Set(jsonvalue.NewUint64(b))

func (*V) String Uses

func (v *V) String() string

String returns represented string value or the description for the jsonvalue.V instance if it is not a string.

Code:

v := jsonvalue.NewObject()
v.SetString("Hello, string").At("object", "message")
fmt.Println(v)

child, _ := v.Get("object")
fmt.Println(child)

child, _ = v.Get("object", "message")
fmt.Println(child)

Output:

{object: {message: Hello, string}}
{message: Hello, string}
Hello, string

func (*V) Uint Uses

func (v *V) Uint() uint

Uint returns represented uint value. If value is not a number, returns zero.

func (*V) Uint32 Uses

func (v *V) Uint32() uint32

Uint32 returns represented uint32 value. If value is not a number, returns zero.

func (*V) Uint64 Uses

func (v *V) Uint64() uint64

Uint64 returns represented uint64 value. If value is not a number, returns zero.

Package jsonvalue imports 7 packages (graph). Updated 2019-11-07. Refresh now. Tools for package owners.