From: Ketan Parmar Date: Thu, 31 Jan 2019 01:58:15 +0000 (+0530) Subject: encoding/json: add example for json.HTMLEscape X-Git-Tag: go1.13beta1~1401 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8cf1d1634a423a9509c54a6cc8e2ec632a8a6e38;p=gostls13.git encoding/json: add example for json.HTMLEscape Change-Id: Ib00fcfd46eae27eea0a3d4cab4406f4c461fb57b Reviewed-on: https://go-review.googlesource.com/c/160517 Reviewed-by: Andrew Bonventre Run-TryBot: Andrew Bonventre TryBot-Result: Gobot Gobot --- 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":"HTML content"}`)) + out.WriteTo(os.Stdout) + // Output: + //{"Name":"\u003cb\u003eHTML content\u003c/b\u003e"} +}