diff --git a/content/en/docs/hertz/tutorials/basic-feature/render.md b/content/en/docs/hertz/tutorials/basic-feature/render.md index 7fcffcd689..43d0dae323 100644 --- a/content/en/docs/hertz/tutorials/basic-feature/render.md +++ b/content/en/docs/hertz/tutorials/basic-feature/render.md @@ -70,17 +70,16 @@ func main() { `JSON` replaces special html characters with their unicode entities, if you want to encode these characters literally,you can use `PureJSON`. Example Code: - ```go func main() { h := server.Default(server.WithHostPorts("127.0.0.1:8080")) - h.GET("/pureJson", func(ctx context.Context, c *app.RequestContext) { c.PureJSON(consts.StatusOK, utils.H{ "html": "

Hello World

", + }) }) - h.Spin() + h.Spin() } ``` @@ -96,24 +95,27 @@ func main() { h.GET("/indentedJSON", func(ctx context.Context, c *app.RequestContext) { var msg struct { - Company string - Location string - Number int - } - msg.Company = "company" - msg.Location = "location" - msg.Number = 123 - - c.IndentedJSON(consts.StatusOK, msg) + Company string + Location string + Number int + } + msg.Company = "company" + msg.Location = "location" + msg.Number = 123 + + c.IndentedJSON(consts.StatusOK, msg) + /* - will output : { - "Company": "company", - "Location": "location", - "Number": 123 - } - */ + will output : + { + "Company": "company", + "Location": "location", + "Number": 123 + } + */ + }) - h.Spin() + h.Spin() } ``` diff --git a/content/zh/docs/hertz/tutorials/basic-feature/render.md b/content/zh/docs/hertz/tutorials/basic-feature/render.md index 0c1f79a991..2d9d2648cf 100644 --- a/content/zh/docs/hertz/tutorials/basic-feature/render.md +++ b/content/zh/docs/hertz/tutorials/basic-feature/render.md @@ -69,9 +69,10 @@ func main() { h.GET("/pureJson", func(ctx context.Context, c *app.RequestContext) { c.PureJSON(consts.StatusOK, utils.H{ "html": "

Hello World

", + }) }) - h.Spin() + h.Spin() } ``` @@ -86,7 +87,7 @@ func main() { h := server.Default(server.WithHostPorts("127.0.0.1:8080")) h.GET("/indentedJSON", func(ctx context.Context, c *app.RequestContext) { - var msg struct { + var msg struct { Company string Location string Number int @@ -95,16 +96,18 @@ func main() { msg.Location = "location" msg.Number = 123 - c.IndentedJSON(consts.StatusOK, msg) - /* - will output : { - "Company": "company", - "Location": "location", - "Number": 123 - } - */ + c.IndentedJSON(consts.StatusOK, msg) + /* + will output : { + "Company": "company", + "Location": "location", + "Number": 123 + } + */ - h.Spin() + }) + + h.Spin() } ```