cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.

Home Page:https://www.cloudwego.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ctx.JSON默认开启HTML转义吗?

ljkk opened this issue · comments

commented
package main

import (
    "context"

    "github.com/cloudwego/hertz/pkg/app"
    "github.com/cloudwego/hertz/pkg/app/server"
    "github.com/cloudwego/hertz/pkg/common/utils"
    "github.com/cloudwego/hertz/pkg/protocol/consts"
)


func main() {
    h := server.Default(server.WithExitWaitTime(0))

    h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {
            ctx.JSON(consts.StatusOK, utils.H{"message": "<>pong<>"})
    })

    h.Spin()

}

// curl http://127.0.0.1:8888/ping,期望返回:{"message":"<>pong<>"},实际返回:{"message":"\u003c\u003epong\u003c\u003e"}

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.