forked from mirror/gjson
added ParseBytes
This commit is contained in:
parent
1a8de7c426
commit
c1e65a498d
8
gjson.go
8
gjson.go
|
@ -334,7 +334,7 @@ end:
|
|||
return
|
||||
}
|
||||
|
||||
// Parse parses the json and returns a result
|
||||
// Parse parses the json and returns a result.
|
||||
func Parse(json string) Result {
|
||||
var value Result
|
||||
for i := 0; i < len(json); i++ {
|
||||
|
@ -372,6 +372,12 @@ func Parse(json string) Result {
|
|||
return value
|
||||
}
|
||||
|
||||
// ParseBytes parses the json and returns a result.
|
||||
// If working with bytes, this method preferred over Parse(string(data))
|
||||
func ParseBytes(json []byte) Result {
|
||||
return Parse(string(json))
|
||||
}
|
||||
|
||||
func squash(json string) string {
|
||||
// expects that the lead character is a '[' or '{'
|
||||
// squash the value, ignoring all nested arrays and objects.
|
||||
|
|
Loading…
Reference in New Issue