{"action":"opened","issue":{"url":"https://api.github.com/repos/astaxie/beego/issues/2153","repository_url":"https://api.github.com/repos/astaxie/beego","labels_url":"https://api.github.com/repos/astaxie/beego/issues/2153/labels{/name}","comments_url":"https://api.github.com/repos/astaxie/beego/issues/2153/comments","events_url":"https://api.github.com/repos/astaxie/beego/issues/2153/events","html_url":"https://github.com/astaxie/beego/issues/2153","id":176059640,"number":2153,"title":"Controller ServeJSON doesn't use square brackets when returning an array","user":{"login":"ronaldwh","id":1446641,"avatar_url":"https://avatars.githubusercontent.com/u/1446641?v=3","gravatar_id":"","url":"https://api.github.com/users/ronaldwh","html_url":"https://github.com/ronaldwh","followers_url":"https://api.github.com/users/ronaldwh/followers","following_url":"https://api.github.com/users/ronaldwh/following{/other_user}","gists_url":"https://api.github.com/users/ronaldwh/gists{/gist_id}","starred_url":"https://api.github.com/users/ronaldwh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ronaldwh/subscriptions","organizations_url":"https://api.github.com/users/ronaldwh/orgs","repos_url":"https://api.github.com/users/ronaldwh/repos","events_url":"https://api.github.com/users/ronaldwh/events{/privacy}","received_events_url":"https://api.github.com/users/ronaldwh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-09T17:07:42Z","updated_at":"2016-09-09T17:07:42Z","closed_at":null,"body":"Please answer these questions before submitting your issue. Thanks!\r\n\r\n1. What version of Go and beego are you using (`bee version`)?\r\ngo: 1.7.0\r\nbeego: 1.5.1\r\n\r\n2. What operating system and processor architecture are you using (`go env`)?\r\nmac os\r\n\r\n3. What did you do?\r\nIf possible, provide a recipe for reproducing the error.\r\nA complete runnable program is good.\r\n\r\nthis is my model class\r\n\r\n```\r\npackage models\r\n\r\nvar (\r\n\tCommentList map[int]Comment\r\n)\r\n\r\ntype Comment struct {\r\n\tNo     string `json:\"no\"`\r\n\tAuthor string `json:\"author\"`\r\n\tText   string `json:\"text\"`\r\n}\r\n\r\nfunc init() {\r\n\tCommentList = make(map[int]Comment)\r\n\tc := Comment{\"1\", \"Pete Hunter\", \"This is not bad comment\"}\r\n\tCommentList[1] = c\r\n\tc2 := Comment{\"2\", \"John Petey\", \"This is too not bad comment\"}\r\n\tCommentList[2] = c2\r\n}\r\n\r\nfunc GetAllComments() map[int]Comment {\r\n\treturn CommentList\r\n}\r\n```\r\n\r\nand this is my controller class \r\n\r\n```\r\npackage controllers\r\n\r\nimport (\r\n\t\"github.com/astaxie/beego\"\r\n\t\"www.site.com/models\"\r\n)\r\n\r\ntype ApiController struct {\r\n\tbeego.Controller\r\n}\r\n\r\nfunc (c *ApiController) Get() {\r\n\tc.TplName = \"react.tpl\"\r\n}\r\n\r\nfunc (c *ApiController) GetComments() {\r\n\tcomments := models.GetAllComments()\r\n\tc.Data[\"json\"] = comments\r\n\tc.ServeJSON()\r\n}\r\n```\r\n4. What did you expect to see?\r\n\r\nthe GetComments controller should return this:\r\n\r\n```\r\n[\r\n  \"1\": {\r\n    \"no\": \"1\",\r\n    \"author\": \"Pete Hunter\",\r\n    \"text\": \"This is not bad comment\"\r\n  },\r\n  \"2\": {\r\n    \"no\": \"2\",\r\n    \"author\": \"John Petey\",\r\n    \"text\": \"This is too not bad comment\"\r\n  }\r\n]\r\n```\r\n\r\n5. What did you see instead?\r\n\r\nbut it returning this instead, the array bracket is using curly bracket instead of square bracket\r\n```\r\n{\r\n  \"1\": {\r\n    \"no\": \"1\",\r\n    \"author\": \"Pete Hunter\",\r\n    \"text\": \"This is not bad comment\"\r\n  },\r\n  \"2\": {\r\n    \"no\": \"2\",\r\n    \"author\": \"John Petey\",\r\n    \"text\": \"This is too not bad comment\"\r\n  }\r\n}\r\n```"}}
{"actor":{"display_login":"ronaldwh"}}