diff options
| author | Ketan Parmar <ketanbparmar@gmail.com> | 2019-01-31 07:28:15 +0530 |
|---|---|---|
| committer | Andrew Bonventre <andybons@golang.org> | 2019-02-26 18:14:45 +0000 |
| commit | 8cf1d1634a423a9509c54a6cc8e2ec632a8a6e38 (patch) | |
| tree | d4c17f6890c2480bda69b7fba3d5cdea0717a17f /src/encoding/json | |
| parent | 15b4c71a912846530315c3e854feaaa9d0d54220 (diff) | |
| download | go-8cf1d1634a423a9509c54a6cc8e2ec632a8a6e38.tar.xz | |
encoding/json: add example for json.HTMLEscape
Change-Id: Ib00fcfd46eae27eea0a3d4cab4406f4c461fb57b
Reviewed-on: https://go-review.googlesource.com/c/160517
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/json')
| -rw-r--r-- | src/encoding/json/example_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/encoding/json/example_test.go b/src/encoding/json/example_test.go index 2031cba793..4c075ddaa6 100644 --- a/src/encoding/json/example_test.go +++ b/src/encoding/json/example_test.go @@ -301,3 +301,11 @@ func ExampleValid() { // Output: // true false } + +func ExampleHTMLEscape() { + var out bytes.Buffer + json.HTMLEscape(&out, []byte(`{"Name":"<b>HTML content</b>"}`)) + out.WriteTo(os.Stdout) + // Output: + //{"Name":"\u003cb\u003eHTML content\u003c/b\u003e"} +} |
