2015-11-18

(beego) JSON Response 작성하기



  • 샘플 코드
    func (c *HappeningController) Get() {
     data := map[string]interface{}{
      "test":  "test",
      "num":   23,
      "array": []string{"one", "two"},
     }
     c.Data["json"] = &data
     c.ServeJson()
    }
  • 결과
    {
        "test":"test",
        "number": 23,
        "array":["one", "two"]
    }

댓글 없음:

댓글 쓰기