From 8a59aea6a68c63a11a6cd61af10aef435f3fa5cc Mon Sep 17 00:00:00 2001 From: John Date: Tue, 23 Jan 2018 15:43:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3gjson=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A3=80=E7=B4=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/encoding/gjson/gjson.go | 3 +++ geg/frame/mvc/controller/demo/upload.go | 2 +- geg/other/test.go | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) 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 := `{