]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/json: add example to Valid
authorhearot <gabriel@hearot.it>
Sat, 27 Oct 2018 18:43:21 +0000 (20:43 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 28 Oct 2018 19:49:25 +0000 (19:49 +0000)
Change-Id: I411483d76a2ca91cd15ff42ae1adb9134486d183
Reviewed-on: https://go-review.googlesource.com/c/145278
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/encoding/json/example_test.go

index 39b3231850a95d3b9f0dbab51eaaafd2d7063f71..2031cba7938927fb08bbd93e05daf9738b7d34fc 100644 (file)
@@ -292,3 +292,12 @@ func ExampleMarshalIndent() {
        // <prefix><indent>"b": 2
        // <prefix>}
 }
+
+func ExampleValid() {
+       goodJSON := `{"example": 1}`
+       badJSON := `{"example":2:]}}`
+
+       fmt.Println(json.Valid([]byte(goodJSON)), json.Valid([]byte(badJSON)))
+       // Output:
+       // true false
+}