From c1e65a498d37a36a3f7dda77fb8cdee7b26940c9 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Fri, 2 Dec 2016 11:59:39 -0700 Subject: [PATCH] added ParseBytes --- gjson.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gjson.go b/gjson.go index c61fbbf..bafabed 100644 --- a/gjson.go +++ b/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.