Commit 3fe9d4c1 authored by hearot's avatar hearot Committed by Brad Fitzpatrick

encoding/json: add example to Valid

Change-Id: I411483d76a2ca91cd15ff42ae1adb9134486d183
Reviewed-on: https://go-review.googlesource.com/c/145278Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3bab4373
...@@ -292,3 +292,12 @@ func ExampleMarshalIndent() { ...@@ -292,3 +292,12 @@ func ExampleMarshalIndent() {
// <prefix><indent>"b": 2 // <prefix><indent>"b": 2
// <prefix>} // <prefix>}
} }
func ExampleValid() {
goodJSON := `{"example": 1}`
badJSON := `{"example":2:]}}`
fmt.Println(json.Valid([]byte(goodJSON)), json.Valid([]byte(badJSON)))
// Output:
// true false
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment