{"action":"created","issue":{"url":"https://api.github.com/repos/univedo/api2go/issues/60","labels_url":"https://api.github.com/repos/univedo/api2go/issues/60/labels{/name}","comments_url":"https://api.github.com/repos/univedo/api2go/issues/60/comments","events_url":"https://api.github.com/repos/univedo/api2go/issues/60/events","html_url":"https://github.com/univedo/api2go/issues/60","id":55976608,"number":60,"title":"Lots of \"links\"","user":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/univedo/api2go/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-30T00:05:03Z","updated_at":"2015-01-30T09:28:54Z","closed_at":null,"body":"I plugged a struct into `api2go.MarshalToJSON` and it gave me a multi-layered object, the middle layer being a `links` object. Super weird:\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"encoding/json\"\r\n\t\"fmt\"\r\n\t\"github.com/univedo/api2go\"\r\n)\r\n\r\ntype Identity struct {\r\n\tUserId int64    `json:\"user_id\"`\r\n\tScopes []string `json:\"scopes\"`\r\n}\r\n\r\ntype Identities struct {\r\n\tIdentities []Identity `json:\"identities\"`\r\n}\r\n\r\nfunc main() {\r\n\tvar response []byte\r\n\r\n\tidentity := Identity{1234, []string{\"user_global\"}}\r\n\r\n\tresponse, _ = api2go.MarshalToJSON(identity)\r\n\tfmt.Println(string(response))\r\n\r\n\tresponse, _ = json.Marshal(Identities{[]Identity{identity}})\r\n\tfmt.Println(string(response))\r\n}\r\n```\r\n\r\nThe outputs:\r\n\r\n```json\r\n{\"identities\":{\"links\":{\"scopes\":[\"user_global\"]},\"userId\":1234}}\r\n{\"identities\":[{\"user_id\":1234,\"scopes\":[\"user_global\"]}]}\r\n```\r\n\r\nThe first is not what I'm looking for, the second *is* what I'm looking for. Am I misunderstanding your API?"},"comment":{"url":"https://api.github.com/repos/univedo/api2go/issues/comments/72175161","html_url":"https://github.com/univedo/api2go/issues/60#issuecomment-72175161","issue_url":"https://api.github.com/repos/univedo/api2go/issues/60","id":72175161,"user":{"login":"wwwdata","id":818880,"avatar_url":"https://avatars.githubusercontent.com/u/818880?v=3","gravatar_id":"","url":"https://api.github.com/users/wwwdata","html_url":"https://github.com/wwwdata","followers_url":"https://api.github.com/users/wwwdata/followers","following_url":"https://api.github.com/users/wwwdata/following{/other_user}","gists_url":"https://api.github.com/users/wwwdata/gists{/gist_id}","starred_url":"https://api.github.com/users/wwwdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wwwdata/subscriptions","organizations_url":"https://api.github.com/users/wwwdata/orgs","repos_url":"https://api.github.com/users/wwwdata/repos","events_url":"https://api.github.com/users/wwwdata/events{/privacy}","received_events_url":"https://api.github.com/users/wwwdata/received_events","type":"User","site_admin":false},"created_at":"2015-01-30T09:28:54Z","updated_at":"2015-01-30T09:28:54Z","body":"Ah, now I see the problem.\r\n\r\n```go\r\ntype Identity struct {\r\n    UserId int64    `json:\"user_id\"`\r\n    Scopes []string `json:\"scopes\"`\r\n}\r\n```\r\n\r\nhere, the field `ID` is missing. In our library it is necessary to always have a field ID. So therefore the strange behavior occurs. If you change it to:\r\n\r\n```go\r\ntype Identity struct {\r\n\tID          int64    \r\n\tScopes []string `json:\"scopes\"`\r\n}\r\n```\r\n\r\nthe output is \r\n\r\n```json\r\n{\r\n    \"identities\": {\r\n        \"id\": \"1234\",\r\n        \"links\": {\r\n            \"scopes\": [\r\n                \"user_global\"\r\n            ]\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nwhich is a little bid better. But there still is the issue that `scopes` gets in the `links` object in the json which in your case is not correct because `Scopes` is not a linked struct, it's a field of `Identity` and we want to achieve this json output as previously posted by you:\r\n\r\n```json\r\n{\r\n    \"identities\": [\r\n        {\r\n            \"id\": 1234,\r\n            \"scopes\": [\r\n                \"user_global\"\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nso, that's what should be fixed, right?"}}