Compare commits
No commits in common. "feature/add-method-jugde" and "master" have entirely different histories.
feature/ad
...
master
26
edb_test.go
26
edb_test.go
|
@ -1,26 +0,0 @@
|
||||||
package gjson
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMethodCase(t *testing.T) {
|
|
||||||
content := `{"name":{"first":"int ","last":"Prichard"}, "age":(47)}`
|
|
||||||
r := Parse(content)
|
|
||||||
|
|
||||||
t.Error(r.Get("age"))
|
|
||||||
|
|
||||||
t.Error(fmt.Sprintf("%#v", r))
|
|
||||||
|
|
||||||
content = `(12+23)`
|
|
||||||
r = Parse(content)
|
|
||||||
|
|
||||||
t.Error(fmt.Sprintf("%#v", r))
|
|
||||||
|
|
||||||
content = `[(12+2), 213, {"name": "das", "key": (23+4)}]`
|
|
||||||
r = Parse(content)
|
|
||||||
|
|
||||||
t.Error(fmt.Sprintf("%#v", r))
|
|
||||||
|
|
||||||
}
|
|
31
gjson.go
31
gjson.go
|
@ -31,8 +31,6 @@ const (
|
||||||
True
|
True
|
||||||
// JSON is a raw block of JSON
|
// JSON is a raw block of JSON
|
||||||
JSON
|
JSON
|
||||||
// Method is for query fucntion
|
|
||||||
Method
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a string representation of the type.
|
// String returns a string representation of the type.
|
||||||
|
@ -52,8 +50,6 @@ func (t Type) String() string {
|
||||||
return "True"
|
return "True"
|
||||||
case JSON:
|
case JSON:
|
||||||
return "JSON"
|
return "JSON"
|
||||||
case Method:
|
|
||||||
return "Method"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +95,6 @@ func (t Result) String() string {
|
||||||
return t.Raw
|
return t.Raw
|
||||||
case True:
|
case True:
|
||||||
return "true"
|
return "true"
|
||||||
case Method:
|
|
||||||
return t.Raw
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,10 +448,6 @@ func Parse(json string) Result {
|
||||||
case '"':
|
case '"':
|
||||||
value.Type = String
|
value.Type = String
|
||||||
value.Raw, value.Str = tostr(json[i:])
|
value.Raw, value.Str = tostr(json[i:])
|
||||||
case '(':
|
|
||||||
value.Type = Method
|
|
||||||
value.Raw = json[i:]
|
|
||||||
value.Str = json[i+1 : len(json)-1]
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -656,9 +646,6 @@ func parseString(json string, i int) (int, string, bool, bool) {
|
||||||
if json[i] == '"' {
|
if json[i] == '"' {
|
||||||
return i + 1, json[s-1 : i+1], false, true
|
return i + 1, json[s-1 : i+1], false, true
|
||||||
}
|
}
|
||||||
if json[i] == ')' {
|
|
||||||
return i + 1, json[s-1 : i+1], false, true
|
|
||||||
}
|
|
||||||
if json[i] == '\\' {
|
if json[i] == '\\' {
|
||||||
i++
|
i++
|
||||||
for ; i < len(json); i++ {
|
for ; i < len(json); i++ {
|
||||||
|
@ -2138,24 +2125,6 @@ func parseAny(json string, i int, hit bool) (int, Result, bool) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch json[i] {
|
switch json[i] {
|
||||||
case '(':
|
|
||||||
i++
|
|
||||||
var vesc bool
|
|
||||||
var ok bool
|
|
||||||
i, val, vesc, ok = parseString(json, i)
|
|
||||||
if !ok {
|
|
||||||
return i, res, false
|
|
||||||
}
|
|
||||||
if hit {
|
|
||||||
res.Type = Method
|
|
||||||
res.Raw = val
|
|
||||||
if vesc {
|
|
||||||
res.Str = unescape(val[1 : len(val)-1])
|
|
||||||
} else {
|
|
||||||
res.Str = val[1 : len(val)-1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return i, res, true
|
|
||||||
case '"':
|
case '"':
|
||||||
i++
|
i++
|
||||||
var vesc bool
|
var vesc bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user