gf: github.com/gogf/gf/encoding/gjson Index | Examples | Files

package gjson

import "github.com/gogf/gf/encoding/gjson"

Package gjson provides convenient API for JSON/XML/INI/YAML/TOML data handling.

Code:

data :=
    `{
    "users" : {
        "count" : 1,
        "array" : ["John", "Ming"]
    }
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    type Users struct {
        Count int
        Array []string
    }
    users := new(Users)
    if err := j.GetStruct("users", users); err != nil {
        panic(err)
    }
    fmt.Printf(`%+v`, users)
}

Output:

&{Count:1 Array:[John Ming]}

Code:

data :=
    `{
    "users" : {
        "count" : 1,
        "array" : ["John", "Ming"]
    }
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    fmt.Println("JSON:")
    fmt.Println(j.MustToJsonString())
    fmt.Println("======================")

    fmt.Println("XML:")
    fmt.Println(j.MustToXmlString())
    fmt.Println("======================")

    fmt.Println("YAML:")
    fmt.Println(j.MustToYamlString())
    fmt.Println("======================")

    fmt.Println("TOML:")
    fmt.Println(j.MustToTomlString())
}

Output:

JSON:
{"users":{"array":["John","Ming"],"count":1}}
======================
XML:
<users><array>John</array><array>Ming</array><count>1</count></users>
======================
YAML:
users:
    array:
      - John
      - Ming
    count: 1

======================
TOML:
[users]
  array = ["John", "Ming"]
  count = 1.0

Code:

data :=
    `
	{
    "count" : 1,
    "array" : ["John", "Ming"]
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    type Users struct {
        Count int
        Array []string
    }
    users := new(Users)
    if err := j.ToStruct(users); err != nil {
        panic(err)
    }
    fmt.Printf(`%+v`, users)
}

Output:

&{Count:1 Array:[John Ming]}

Code:

j := gjson.New(nil)
j.Set("name", "John")
j.Set("score", 99.5)
fmt.Printf(
    "Name: %s, Score: %v\n",
    j.GetString("name"),
    j.GetFloat32("score"),
)
fmt.Println(j.MustToJsonString())

Output:

Name: John, Score: 99.5
{"name":"John","score":99.5}

Code:

j := gjson.New(nil)
for i := 0; i < 5; i++ {
    j.Set(fmt.Sprintf(`%d.id`, i), i)
    j.Set(fmt.Sprintf(`%d.name`, i), fmt.Sprintf(`student-%d`, i))
}
fmt.Println(j.MustToJsonString())

Output:

[{"id":0,"name":"student-0"},{"id":1,"name":"student-1"},{"id":2,"name":"student-2"},{"id":3,"name":"student-3"},{"id":4,"name":"student-4"}]

Code:

data :=
    `{
    "users" : {
        "count" : 2,
        "list"  : [
            {"name" : "Ming", "score" : 60},
            {"name" : "John", "score" : 59}
        ]
    }
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    j.Set("users.list.1.score", 100)
    fmt.Println("John Score:", j.GetFloat32("users.list.1.score"))
    fmt.Println(j.MustToJsonString())
}

Output:

John Score: 100
{"users":{"count":2,"list":[{"name":"Ming","score":60},{"name":"John","score":100}]}}

Code:

jsonContent := `{"name":"john", "score":"100"}`
j, _ := gjson.LoadContent(jsonContent)
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))

Output:

john
100

Code:

jsonFilePath := gdebug.TestDataPath("json", "data1.json")
j, _ := gjson.Load(jsonFilePath)
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))

Code:

jsonFilePath := gdebug.TestDataPath("xml", "data1.xml")
j, _ := gjson.Load(jsonFilePath)
fmt.Println(j.Get("doc.name"))
fmt.Println(j.Get("doc.score"))

Code:

jsonContent := `{"map":{"key":"value"}, "slice":[59,90]}`
j, _ := gjson.LoadJson(jsonContent)
m := j.GetMap("map")
fmt.Println(m)

// Change the key-value pair.
m["key"] = "john"

// It changes the underlying key-value pair.
fmt.Println(j.GetMap("map"))

s := j.GetArray("slice")
fmt.Println(s)

// Change the value of specified index.
s[0] = 100

// It changes the underlying slice.
fmt.Println(j.GetArray("slice"))

Output:

map[key:value]
map[key:john]
[59 90]
[100 90]

Code:

jsonContent := `{"name":"john", "score":"100"}`
j := gjson.New(jsonContent)
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))

Output:

john
100

Code:

type Me struct {
    Name  string `json:"name"`
    Score int    `json:"score"`
}
me := Me{
    Name:  "john",
    Score: 100,
}
j := gjson.New(me)
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))

Output:

john
100

Code:

type Me struct {
    Name  string `tag:"name"`
    Score int    `tag:"score"`
    Title string
}
me := Me{
    Name:  "john",
    Score: 100,
    Title: "engineer",
}
// The parameter <tags> specifies custom priority tags for struct conversion to map,
// multiple tags joined with char ','.
j := gjson.NewWithTag(me, "tag")
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))
fmt.Println(j.Get("Title"))

Output:

john
100
engineer

Code:

jsonContent := `<?xml version="1.0" encoding="UTF-8"?><doc><name>john</name><score>100</score></doc>`
j := gjson.New(jsonContent)
// Note that there's root node in the XML content.
fmt.Println(j.Get("doc.name"))
fmt.Println(j.Get("doc.score"))

Output:

john
100

Code:

data :=
    `{
    "users" : {
        "count" : 2,
        "list"  : [
            {"name" : "Ming",  "score" : 60},
            {"name" : "John", "score" : 99.5}
        ]
    }
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    j.SetSplitChar('#')
    fmt.Println("John Score:", j.GetFloat32("users#list#1#score"))
}

Output:

John Score: 99.5

Code:

data :=
    `{
    "users" : {
        "count" : 2,
        "list"  : [
            {"name" : "Ming",  "score" : 60},
            {"name" : "John", "score" : 99.5}
        ]
    }
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    fmt.Println("John Score:", j.GetFloat32("users.list.1.score"))
}

Output:

John Score: 99.5

Code:

data :=
    `{
    "users" : {
        "count" : 100
    },
    "users.count" : 101
}`
if j, err := gjson.DecodeToJson(data); err != nil {
    panic(err)
} else {
    j.SetViolenceCheck(true)
    fmt.Println("Users Count:", j.GetInt("users.count"))
}

Output:

Users Count: 101

Index

Examples

Package Files

gjson.go gjson_api.go gjson_api_config.go gjson_api_encoding.go gjson_api_new_load.go gjson_implements.go gjson_stdlib_json_util.go

func Decode Uses

func Decode(data interface{}) (interface{}, error)

Decode decodes json format <data> to golang variable. The parameter <data> can be either bytes or string type.

func DecodeTo Uses

func DecodeTo(data interface{}, v interface{}) error

Decode decodes json format <data> to specified golang variable <v>. The parameter <data> can be either bytes or string type. The parameter <v> should be a pointer type.

func Encode Uses

func Encode(value interface{}) ([]byte, error)

Encode encodes any golang variable <value> to JSON bytes.

func Valid Uses

func Valid(data interface{}) bool

Valid checks whether <data> is a valid JSON data type. The parameter <data> specifies the json format data, which can be either bytes or string type.

type Json Uses

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

The customized JSON struct.

func DecodeToJson Uses

func DecodeToJson(data interface{}, safe ...bool) (*Json, error)

DecodeToJson codes json format <data> to a Json object. The parameter <data> can be either bytes or string type.

func Load Uses

func Load(path string, safe ...bool) (*Json, error)

Load loads content from specified file <path>, and creates a Json object from its content.

func LoadContent Uses

func LoadContent(data interface{}, safe ...bool) (*Json, error)

LoadContent creates a Json object from given content, it checks the data type of <content> automatically, supporting data content type as follows: JSON, XML, INI, YAML and TOML.

func LoadIni Uses

func LoadIni(data interface{}, safe ...bool) (*Json, error)

LoadIni creates a Json object from given INI format content.

func LoadJson Uses

func LoadJson(data interface{}, safe ...bool) (*Json, error)

LoadJson creates a Json object from given JSON format content.

func LoadToml Uses

func LoadToml(data interface{}, safe ...bool) (*Json, error)

LoadToml creates a Json object from given TOML format content.

func LoadXml Uses

func LoadXml(data interface{}, safe ...bool) (*Json, error)

LoadXml creates a Json object from given XML format content.

func LoadYaml Uses

func LoadYaml(data interface{}, safe ...bool) (*Json, error)

LoadYaml creates a Json object from given YAML format content.

func New Uses

func New(data interface{}, safe ...bool) *Json

New creates a Json object with any variable type of <data>, but <data> should be a map or slice for data access reason, or it will make no sense.

The parameter <safe> specifies whether using this Json object in concurrent-safe context, which is false in default.

func NewWithTag Uses

func NewWithTag(data interface{}, tags string, safe ...bool) *Json

NewWithTag creates a Json object with any variable type of <data>, but <data> should be a map or slice for data access reason, or it will make no sense.

The parameter <tags> specifies priority tags for struct conversion to map, multiple tags joined with char ','.

The parameter <safe> specifies whether using this Json object in concurrent-safe context, which is false in default.

func (*Json) Append Uses

func (j *Json) Append(pattern string, value interface{}) error

Append appends value to the value by specified <pattern>. The target value by <pattern> should be type of slice.

func (*Json) Contains Uses

func (j *Json) Contains(pattern string) bool

Contains checks whether the value by specified <pattern> exist.

func (*Json) Dump Uses

func (j *Json) Dump()

Dump prints current Json object with more manually readable.

func (*Json) Export Uses

func (j *Json) Export() string

Export returns <j> as a string with more manually readable.

func (*Json) Get Uses

func (j *Json) Get(pattern string, def ...interface{}) interface{}

Get retrieves and returns value by specified <pattern>. It returns all values of current Json object if <pattern> is given empty or string ".". It returns nil if no value found by <pattern>.

We can also access slice item by its index number in <pattern> like: "list.10", "array.0.name", "array.0.1.id".

It returns a default value specified by <def> if value for <pattern> is not found.

func (*Json) GetArray Uses

func (j *Json) GetArray(pattern string, def ...interface{}) []interface{}

GetArray retrieves the value by specified <pattern>, and converts it to a slice of []interface{}.

func (*Json) GetBool Uses

func (j *Json) GetBool(pattern string, def ...interface{}) bool

GetBool retrieves the value by specified <pattern>, converts and returns it as bool. It returns false when value is: "", 0, false, off, nil; or returns true instead.

func (*Json) GetBytes Uses

func (j *Json) GetBytes(pattern string, def ...interface{}) []byte

GetBytes retrieves the value by specified <pattern> and converts it to []byte.

func (*Json) GetDuration Uses

func (j *Json) GetDuration(pattern string, def ...interface{}) time.Duration

GetDuration retrieves the value by specified <pattern> and converts it to time.Duration.

func (*Json) GetFloat32 Uses

func (j *Json) GetFloat32(pattern string, def ...interface{}) float32

GetFloat32 retrieves the value by specified <pattern> and converts it to float32.

func (*Json) GetFloat64 Uses

func (j *Json) GetFloat64(pattern string, def ...interface{}) float64

GetFloat64 retrieves the value by specified <pattern> and converts it to float64.

func (*Json) GetFloats Uses

func (j *Json) GetFloats(pattern string, def ...interface{}) []float64

GetFloats retrieves the value by specified <pattern> and converts it to []float64.

func (*Json) GetGTime Uses

func (j *Json) GetGTime(pattern string, format ...string) *gtime.Time

GetGTime retrieves the value by specified <pattern> and converts it to *gtime.Time.

func (*Json) GetInt Uses

func (j *Json) GetInt(pattern string, def ...interface{}) int

GetInt retrieves the value by specified <pattern> and converts it to int.

func (*Json) GetInt16 Uses

func (j *Json) GetInt16(pattern string, def ...interface{}) int16

GetInt16 retrieves the value by specified <pattern> and converts it to int16.

func (*Json) GetInt32 Uses

func (j *Json) GetInt32(pattern string, def ...interface{}) int32

GetInt32 retrieves the value by specified <pattern> and converts it to int32.

func (*Json) GetInt64 Uses

func (j *Json) GetInt64(pattern string, def ...interface{}) int64

GetInt64 retrieves the value by specified <pattern> and converts it to int64.

func (*Json) GetInt8 Uses

func (j *Json) GetInt8(pattern string, def ...interface{}) int8

GetInt8 retrieves the value by specified <pattern> and converts it to int8.

func (*Json) GetInterfaces Uses

func (j *Json) GetInterfaces(pattern string, def ...interface{}) []interface{}

GetInterfaces is alias of GetArray. See GetArray.

func (*Json) GetInts Uses

func (j *Json) GetInts(pattern string, def ...interface{}) []int

GetInts retrieves the value by specified <pattern> and converts it to []int.

func (*Json) GetJson Uses

func (j *Json) GetJson(pattern string, def ...interface{}) *Json

GetJson gets the value by specified <pattern>, and converts it to a un-concurrent-safe Json object.

func (*Json) GetJsonMap Uses

func (j *Json) GetJsonMap(pattern string, def ...interface{}) map[string]*Json

GetJsonMap gets the value by specified <pattern>, and converts it to a map of un-concurrent-safe Json object.

func (*Json) GetJsons Uses

func (j *Json) GetJsons(pattern string, def ...interface{}) []*Json

GetJsons gets the value by specified <pattern>, and converts it to a slice of un-concurrent-safe Json object.

func (*Json) GetMap Uses

func (j *Json) GetMap(pattern string, def ...interface{}) map[string]interface{}

GetMap retrieves and returns the value by specified <pattern> as map[string]interface{}.

func (*Json) GetMapStrStr Uses

func (j *Json) GetMapStrStr(pattern string, def ...interface{}) map[string]string

GetMapStrStr retrieves and returns the value by specified <pattern> as map[string]string.

func (*Json) GetMapToMap Uses

func (j *Json) GetMapToMap(pattern string, pointer interface{}, mapping ...map[string]string) error

GetMapToMap retrieves the value by specified <pattern> and converts it to specified map variable. See gconv.MapToMap.

func (*Json) GetMapToMapDeep Uses

func (j *Json) GetMapToMapDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

GetMapToMapDeep retrieves the value by specified <pattern> and converts it to specified map variable recursively. See gconv.MapToMapDeep.

func (*Json) GetMapToMaps Uses

func (j *Json) GetMapToMaps(pattern string, pointer interface{}, mapping ...map[string]string) error

GetMapToMaps retrieves the value by specified <pattern> and converts it to specified map slice variable. See gconv.MapToMaps.

func (*Json) GetMapToMapsDeep Uses

func (j *Json) GetMapToMapsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

GetMapToMapsDeep retrieves the value by specified <pattern> and converts it to specified map slice variable recursively. See gconv.MapToMapsDeep.

func (*Json) GetMaps Uses

func (j *Json) GetMaps(pattern string, def ...interface{}) []map[string]interface{}

GetMaps retrieves and returns the value by specified <pattern> as []map[string]interface{}.

func (*Json) GetScan Uses

func (j *Json) GetScan(pattern string, pointer interface{}, mapping ...map[string]string) error

GetScan automatically calls Struct or Structs function according to the type of parameter <pointer> to implement the converting..

func (*Json) GetScanDeep Uses

func (j *Json) GetScanDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

GetScanDeep automatically calls StructDeep or StructsDeep function according to the type of parameter <pointer> to implement the converting..

func (*Json) GetString Uses

func (j *Json) GetString(pattern string, def ...interface{}) string

GetString retrieves the value by specified <pattern> and converts it to string.

func (*Json) GetStrings Uses

func (j *Json) GetStrings(pattern string, def ...interface{}) []string

GetStrings retrieves the value by specified <pattern> and converts it to []string.

func (*Json) GetStruct Uses

func (j *Json) GetStruct(pattern string, pointer interface{}, mapping ...map[string]string) error

GetStruct retrieves the value by specified <pattern> and converts it to specified object <pointer>. The <pointer> should be the pointer to an object.

func (*Json) GetStructDeep Uses

func (j *Json) GetStructDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

GetStructDeep does GetStruct recursively.

func (*Json) GetStructs Uses

func (j *Json) GetStructs(pattern string, pointer interface{}, mapping ...map[string]string) error

GetStructs converts any slice to given struct slice.

func (*Json) GetStructsDeep Uses

func (j *Json) GetStructsDeep(pattern string, pointer interface{}, mapping ...map[string]string) error

GetStructsDeep converts any slice to given struct slice recursively.

func (*Json) GetTime Uses

func (j *Json) GetTime(pattern string, format ...string) time.Time

GetTime retrieves the value by specified <pattern> and converts it to time.Time.

func (*Json) GetUint Uses

func (j *Json) GetUint(pattern string, def ...interface{}) uint

GetUint retrieves the value by specified <pattern> and converts it to uint.

func (*Json) GetUint16 Uses

func (j *Json) GetUint16(pattern string, def ...interface{}) uint16

GetUint16 retrieves the value by specified <pattern> and converts it to uint16.

func (*Json) GetUint32 Uses

func (j *Json) GetUint32(pattern string, def ...interface{}) uint32

GetUint32 retrieves the value by specified <pattern> and converts it to uint32.

func (*Json) GetUint64 Uses

func (j *Json) GetUint64(pattern string, def ...interface{}) uint64

GetUint64 retrieves the value by specified <pattern> and converts it to uint64.

func (*Json) GetUint8 Uses

func (j *Json) GetUint8(pattern string, def ...interface{}) uint8

GetUint8 retrieves the value by specified <pattern> and converts it to uint8.

func (*Json) GetVar Uses

func (j *Json) GetVar(pattern string, def ...interface{}) *gvar.Var

GetVar returns a gvar.Var with value by given <pattern>.

func (*Json) GetVars Uses

func (j *Json) GetVars(pattern string, def ...interface{}) []*gvar.Var

GetVars returns []*gvar.Var with value by given <pattern>.

func (*Json) IsNil Uses

func (j *Json) IsNil() bool

IsNil checks whether the value pointed by <j> is nil.

func (*Json) Len Uses

func (j *Json) Len(pattern string) int

Len returns the length/size of the value by specified <pattern>. The target value by <pattern> should be type of slice or map. It returns -1 if the target value is not found, or its type is invalid.

func (*Json) MarshalJSON Uses

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

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Json) MustToIni Uses

func (j *Json) MustToIni() []byte

func (*Json) MustToIniString Uses

func (j *Json) MustToIniString() string

func (*Json) MustToJson Uses

func (j *Json) MustToJson() []byte

func (*Json) MustToJsonIndent Uses

func (j *Json) MustToJsonIndent() []byte

func (*Json) MustToJsonIndentString Uses

func (j *Json) MustToJsonIndentString() string

func (*Json) MustToJsonString Uses

func (j *Json) MustToJsonString() string

func (*Json) MustToToml Uses

func (j *Json) MustToToml() []byte

func (*Json) MustToTomlString Uses

func (j *Json) MustToTomlString() string

func (*Json) MustToXml Uses

func (j *Json) MustToXml(rootTag ...string) []byte

func (*Json) MustToXmlIndent Uses

func (j *Json) MustToXmlIndent(rootTag ...string) []byte

func (*Json) MustToXmlIndentString Uses

func (j *Json) MustToXmlIndentString(rootTag ...string) string

func (*Json) MustToXmlString Uses

func (j *Json) MustToXmlString(rootTag ...string) string

func (*Json) MustToYaml Uses

func (j *Json) MustToYaml() []byte

func (*Json) MustToYamlString Uses

func (j *Json) MustToYamlString() string

func (*Json) Remove Uses

func (j *Json) Remove(pattern string) error

Remove deletes value with specified <pattern>. It supports hierarchical data access by char separator, which is '.' in default.

func (*Json) Set Uses

func (j *Json) Set(pattern string, value interface{}) error

Set sets value with specified <pattern>. It supports hierarchical data access by char separator, which is '.' in default.

func (*Json) SetSplitChar Uses

func (j *Json) SetSplitChar(char byte)

SetSplitChar sets the separator char for hierarchical data access.

func (*Json) SetViolenceCheck Uses

func (j *Json) SetViolenceCheck(enabled bool)

SetViolenceCheck enables/disables violence check for hierarchical data access.

func (*Json) ToArray Uses

func (j *Json) ToArray() []interface{}

ToArray converts current Json object to []interface{}. It returns nil if fails.

func (*Json) ToIni Uses

func (j *Json) ToIni() ([]byte, error)

func (*Json) ToIniString Uses

func (j *Json) ToIniString() (string, error)

func (*Json) ToJson Uses

func (j *Json) ToJson() ([]byte, error)

func (*Json) ToJsonIndent Uses

func (j *Json) ToJsonIndent() ([]byte, error)

func (*Json) ToJsonIndentString Uses

func (j *Json) ToJsonIndentString() (string, error)

func (*Json) ToJsonString Uses

func (j *Json) ToJsonString() (string, error)

func (*Json) ToMap Uses

func (j *Json) ToMap() map[string]interface{}

ToMap converts current Json object to map[string]interface{}. It returns nil if fails.

func (*Json) ToMapToMap Uses

func (j *Json) ToMapToMap(pointer interface{}, mapping ...map[string]string) error

ToMapToMap converts current Json object to specified map variable. The parameter of <pointer> should be type of *map.

func (*Json) ToMapToMapDeep Uses

func (j *Json) ToMapToMapDeep(pointer interface{}, mapping ...map[string]string) error

ToMapToMapDeep converts current Json object to specified map variable recursively. The parameter of <pointer> should be type of *map.

func (*Json) ToMapToMaps Uses

func (j *Json) ToMapToMaps(pointer interface{}, mapping ...map[string]string) error

ToMapToMaps converts current Json object to specified map variable slice. The parameter of <pointer> should be type of []map/*map.

func (*Json) ToMapToMapsDeep Uses

func (j *Json) ToMapToMapsDeep(pointer interface{}, mapping ...map[string]string) error

ToMapToMapsDeep converts current Json object to specified map variable slice recursively. The parameter of <pointer> should be type of []map/*map.

func (*Json) ToScan Uses

func (j *Json) ToScan(pointer interface{}, mapping ...map[string]string) error

ToScan automatically calls Struct or Structs function according to the type of parameter <pointer> to implement the converting..

func (*Json) ToScanDeep Uses

func (j *Json) ToScanDeep(pointer interface{}, mapping ...map[string]string) error

ToScanDeep automatically calls StructDeep or StructsDeep function according to the type of parameter <pointer> to implement the converting..

func (*Json) ToStruct Uses

func (j *Json) ToStruct(pointer interface{}, mapping ...map[string]string) error

ToStruct converts current Json object to specified object. The <pointer> should be a pointer type of *struct.

func (*Json) ToStructDeep Uses

func (j *Json) ToStructDeep(pointer interface{}, mapping ...map[string]string) error

ToStructDeep converts current Json object to specified object recursively. The <pointer> should be a pointer type of *struct.

func (*Json) ToStructs Uses

func (j *Json) ToStructs(pointer interface{}, mapping ...map[string]string) error

ToStructs converts current Json object to specified object slice. The <pointer> should be a pointer type of []struct/*struct.

func (*Json) ToStructsDeep Uses

func (j *Json) ToStructsDeep(pointer interface{}, mapping ...map[string]string) error

ToStructsDeep converts current Json object to specified object slice recursively. The <pointer> should be a pointer type of []struct/*struct.

func (*Json) ToToml Uses

func (j *Json) ToToml() ([]byte, error)

func (*Json) ToTomlString Uses

func (j *Json) ToTomlString() (string, error)

func (*Json) ToXml Uses

func (j *Json) ToXml(rootTag ...string) ([]byte, error)

func (*Json) ToXmlIndent Uses

func (j *Json) ToXmlIndent(rootTag ...string) ([]byte, error)

func (*Json) ToXmlIndentString Uses

func (j *Json) ToXmlIndentString(rootTag ...string) (string, error)

func (*Json) ToXmlString Uses

func (j *Json) ToXmlString(rootTag ...string) (string, error)

func (*Json) ToYaml Uses

func (j *Json) ToYaml() ([]byte, error)

func (*Json) ToYamlString Uses

func (j *Json) ToYamlString() (string, error)

func (*Json) UnmarshalJSON Uses

func (j *Json) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

func (*Json) UnmarshalValue Uses

func (j *Json) UnmarshalValue(value interface{}) error

UnmarshalValue is an interface implement which sets any type of value for Json.

func (*Json) Value Uses

func (j *Json) Value() interface{}

Value returns the json value.

Package gjson imports 20 packages (graph) and is imported by 9 packages. Updated 2020-07-31. Refresh now. Tools for package owners.