diff options
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 +} |
