mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
Modify Function Name
This commit is contained in:
@ -60,7 +60,7 @@ func Example_conversionNormalFormats() {
|
||||
// count = 1.0
|
||||
}
|
||||
|
||||
func Example_conversionGetStruct() {
|
||||
func ExampleJson_ConversionGetStruct() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
@ -86,7 +86,7 @@ func Example_conversionGetStruct() {
|
||||
// &{Count:1 Array:[John Ming]}
|
||||
}
|
||||
|
||||
func Example_conversionToStruct() {
|
||||
func ExampleJson_ConversionToStruct() {
|
||||
data :=
|
||||
`
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
)
|
||||
|
||||
func Example_dataSetCreate1() {
|
||||
func ExampleJson_DataSetCreate1() {
|
||||
j := gjson.New(nil)
|
||||
j.Set("name", "John")
|
||||
j.Set("score", 99.5)
|
||||
@ -28,7 +28,7 @@ func Example_dataSetCreate1() {
|
||||
// {"name":"John","score":99.5}
|
||||
}
|
||||
|
||||
func Example_dataSetCreate2() {
|
||||
func ExampleJson_DataSetCreate2() {
|
||||
j := gjson.New(nil)
|
||||
for i := 0; i < 5; i++ {
|
||||
j.Set(fmt.Sprintf(`%d.id`, i), i)
|
||||
@ -40,7 +40,7 @@ func Example_dataSetCreate2() {
|
||||
// [{"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"}]
|
||||
}
|
||||
|
||||
func Example_dataSetRuntimeEdit() {
|
||||
func ExampleJson_DataSetRuntimeEdit() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
|
||||
@ -158,7 +158,7 @@ func ExampleIsValidDataType() {
|
||||
// false
|
||||
}
|
||||
|
||||
func Example_loadXml() {
|
||||
func ExampleLoad_Xml() {
|
||||
jsonFilePath := gdebug.TestDataPath("xml", "data1.xml")
|
||||
j, _ := gjson.Load(jsonFilePath)
|
||||
fmt.Println(j.Get("doc.name"))
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
)
|
||||
|
||||
func Example_patternGet() {
|
||||
func ExampleDecodeToJson_PatternGet() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
@ -32,7 +32,7 @@ func Example_patternGet() {
|
||||
// John Score: 99.5
|
||||
}
|
||||
|
||||
func Example_patternViolenceCheck() {
|
||||
func ExampleDecodeToJson_PatternViolenceCheck() {
|
||||
data :=
|
||||
`{
|
||||
"users" : {
|
||||
@ -50,7 +50,7 @@ func Example_patternViolenceCheck() {
|
||||
// Users Count: 101
|
||||
}
|
||||
|
||||
func Example_mapSliceChange() {
|
||||
func ExampleJson_Get_MapSliceChange() {
|
||||
jsonContent := `{"map":{"key":"value"}, "slice":[59,90]}`
|
||||
j, _ := gjson.LoadJson(jsonContent)
|
||||
m := j.Get("map").Map()
|
||||
|
||||
@ -677,13 +677,27 @@ func ExampleJson_UnmarshalJSON() {
|
||||
// map[Age:18 Name:John]
|
||||
}
|
||||
|
||||
func ExampleJson_UnmarshalValue_Yaml() {
|
||||
yamlContent :=
|
||||
`base:
|
||||
name: john
|
||||
score: 100`
|
||||
|
||||
j := gjson.New("")
|
||||
j.UnmarshalValue([]byte(yamlContent))
|
||||
fmt.Println(j.Var().String())
|
||||
|
||||
// Output:
|
||||
// {"base":{"name":"john","score":100}}
|
||||
}
|
||||
|
||||
func ExampleJson_UnmarshalValue_Xml() {
|
||||
xmlStr := `<doc><Age>18</Age><Name>John</Name></doc>`
|
||||
xmlStr := `<?xml version="1.0" encoding="UTF-8"?><doc><name>john</name><score>100</score></doc>`
|
||||
|
||||
j := gjson.New("")
|
||||
j.UnmarshalValue([]byte(xmlStr))
|
||||
fmt.Println(j.Var().String())
|
||||
|
||||
// Output:
|
||||
// {"doc":{"Age":"18","Name":"John"}}
|
||||
// {"doc":{"name":"john","score":"100"}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user