Skip to content

Commit

Permalink
docs: fix error in render (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
welkeyever authored Jul 24, 2024
1 parent 9770a08 commit 34e4f87
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
40 changes: 21 additions & 19 deletions content/en/docs/hertz/tutorials/basic-feature/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<p> Hello World </p>",
})
})

h.Spin()
h.Spin()
}
```

Expand All @@ -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()
}
```

Expand Down
25 changes: 14 additions & 11 deletions content/zh/docs/hertz/tutorials/basic-feature/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ func main() {
h.GET("/pureJson", func(ctx context.Context, c *app.RequestContext) {
c.PureJSON(consts.StatusOK, utils.H{
"html": "<p> Hello World </p>",
})
})

h.Spin()
h.Spin()
}
```

Expand All @@ -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
Expand All @@ -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()
}
```

Expand Down

0 comments on commit 34e4f87

Please sign in to comment.