{
"type": "object",
"properties": {
"firstName": {
"type": "string",
"title": "First name",
"default": "Chuck"
},
"lastName": {
"type": "string",
"title": "Last name"
},
"telephone": {
"type": "string",
"title": "Telephone",
"minLength": 10
}
}
}
我想构造上图所示的数据,并发送到前端进行渲染。它必须包含类型和属性字段。属性中的字段是核心数据。
//testMap is a map. key is variable name , value is value
testMap := DrawValueNameFromPareSelfFile(testPath)
marshal, _ := json.MarshalIndent(testMap, "", " ")
res := string(marshal)
helper.Ok(c, res)
type Resp struct {
Code errcode.Code `json:"code" binding:"required"`
Message string `json:"message" binding:"required"`
Data interface{} `json:"data" binding:"required"`
}
// Ok
func Ok(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, Resp{
Code: errcode.ErrNone,
Data: data,
})
}
忽然笑
蝴蝶刀刀
随时随地看视频慕课网APP
相关分类