mirror of
https://github.com/golang/go
synced 2024-11-07 10:26:20 -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:
parent
3bab4373c7
commit
3fe9d4c1c8
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user