diff --git a/g/encoding/gjson/gjson.go b/g/encoding/gjson/gjson.go index 683b5f6d8..418802cbe 100644 --- a/g/encoding/gjson/gjson.go +++ b/g/encoding/gjson/gjson.go @@ -311,6 +311,9 @@ func (j *Json) getPointerByPattern(pattern string) *interface{} { } } else { index = strings.LastIndex(pattern[start:index], ".") + if index != -1 && length > 0 { + index += length + 1 + } } if start >= index { break diff --git a/geg/frame/mvc/controller/demo/upload.go b/geg/frame/mvc/controller/demo/upload.go index 0432d4cb7..30d32ff7b 100644 --- a/geg/frame/mvc/controller/demo/upload.go +++ b/geg/frame/mvc/controller/demo/upload.go @@ -12,7 +12,7 @@ func Upload(r *ghttp.Request) { buffer := make([]byte, h.Size) f.Read(buffer) gfile.PutBinContents("/tmp/" + fname, buffer) - r.Response.WriteString(fname + " uploaded successly")) + r.Response.WriteString(fname + " uploaded successly") } else { r.Response.WriteString(e.Error()) } diff --git a/geg/other/test.go b/geg/other/test.go index 6d300483d..ef7870d14 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -7,9 +7,10 @@ import ( ) func main() { - j, _ := gjson.Load("/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/geg/frame/config.json") - c, _ := j.ToToml() - fmt.Println(string(c)) + j, _ := gjson.Load("/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/geg/frame/config.yml") + //c, _ := j.ToToml() + //fmt.Println(j.Get("database.default").([]interface{})[0]) + fmt.Println(j.Get("database.default.0")) return data := `{