From 3fe9d4c1c89f2a10e78780c421a2f5d93f218061 Mon Sep 17 00:00:00 2001 From: hearot Date: Sat, 27 Oct 2018 20:43:21 +0200 Subject: [PATCH] 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 --- src/encoding/json/example_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/encoding/json/example_test.go b/src/encoding/json/example_test.go index 39b3231850a..2031cba7938 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 +}