From: hearot Date: Sat, 27 Oct 2018 18:43:21 +0000 (+0200) Subject: encoding/json: add example to Valid X-Git-Tag: go1.12beta1~610 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3fe9d4c1c89f2a10e78780c421a2f5d93f218061;p=gostls13.git encoding/json: add example to Valid Change-Id: I411483d76a2ca91cd15ff42ae1adb9134486d183 Reviewed-on: https://go-review.googlesource.com/c/145278 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/encoding/json/example_test.go b/src/encoding/json/example_test.go index 39b3231850..2031cba793 100644 --- a/src/encoding/json/example_test.go +++ b/src/encoding/json/example_test.go @@ -292,3 +292,12 @@ func ExampleMarshalIndent() { // "b": 2 // } } + +func ExampleValid() { + goodJSON := `{"example": 1}` + badJSON := `{"example":2:]}}` + + fmt.Println(json.Valid([]byte(goodJSON)), json.Valid([]byte(badJSON))) + // Output: + // true false +}