1
0
mirror of https://github.com/golang/go synced 2024-11-07 08:36:28 -07:00

encoding/json: add example to Valid

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>
This commit is contained in:
hearot 2018-10-27 20:43:21 +02:00 committed by Brad Fitzpatrick
parent 3bab4373c7
commit 3fe9d4c1c8

View 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
}