diff options
| author | hearot <gabriel@hearot.it> | 2018-10-27 20:43:21 +0200 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-10-28 19:49:25 +0000 |
| commit | 3fe9d4c1c89f2a10e78780c421a2f5d93f218061 (patch) | |
| tree | 00da8f23a9453ccdb50f4078d82dc46f28461b4d /src/encoding/json/example_test.go | |
| parent | 3bab4373c7bcff8415da8f4560a3297d1c158e16 (diff) | |
| download | go-3fe9d4c1c89f2a10e78780c421a2f5d93f218061.tar.xz | |
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>
Diffstat (limited to 'src/encoding/json/example_test.go')
| -rw-r--r-- | src/encoding/json/example_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
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() { // <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 +} |
