{"action":"opened","issue":{"url":"https://api.github.com/repos/SwiftyJSON/SwiftyJSON/issues/777","repository_url":"https://api.github.com/repos/SwiftyJSON/SwiftyJSON","labels_url":"https://api.github.com/repos/SwiftyJSON/SwiftyJSON/issues/777/labels{/name}","comments_url":"https://api.github.com/repos/SwiftyJSON/SwiftyJSON/issues/777/comments","events_url":"https://api.github.com/repos/SwiftyJSON/SwiftyJSON/issues/777/events","html_url":"https://github.com/SwiftyJSON/SwiftyJSON/issues/777","id":198863063,"number":777,"title":"Remove key and value from JSON","user":{"login":"justinmakaila","id":1638996,"avatar_url":"https://avatars.githubusercontent.com/u/1638996?v=3","gravatar_id":"","url":"https://api.github.com/users/justinmakaila","html_url":"https://github.com/justinmakaila","followers_url":"https://api.github.com/users/justinmakaila/followers","following_url":"https://api.github.com/users/justinmakaila/following{/other_user}","gists_url":"https://api.github.com/users/justinmakaila/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmakaila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmakaila/subscriptions","organizations_url":"https://api.github.com/users/justinmakaila/orgs","repos_url":"https://api.github.com/users/justinmakaila/repos","events_url":"https://api.github.com/users/justinmakaila/events{/privacy}","received_events_url":"https://api.github.com/users/justinmakaila/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-05T02:39:23Z","updated_at":"2017-01-05T02:39:23Z","closed_at":null,"body":"Hey guys, this is more of a code review question... I'm trying to build an object which can handle responses from my API. It looks like this:\r\n```\r\npublic struct Response {\r\n    public let data: JSON\r\n    public let errors: [JSON]\r\n    \r\n    public var isError: Bool {\r\n        return (data.isEmpty || data.type == .null) && !errors.isEmpty\r\n    }\r\n    \r\n    public init(data: JSON, errors: [JSON]) {\r\n        self.data = data\r\n        self.errors = errors\r\n    }\r\n    \r\n    public init(json: JSON) {\r\n        let error = json[\"error\"]\r\n        var errors = json[\"errors\"].array ?? []\r\n        \r\n        if !error.isEmpty && error.type != .null {\r\n            errors.append(error)\r\n        }\r\n        \r\n        self.errors = errors\r\n        \r\n        var data = json.dictionaryValue\r\n        data[\"error\"] = nil\r\n        data[\"errors\"] = nil\r\n        \r\n        self.data = JSON(data)\r\n    }\r\n}\r\n```\r\n\r\nI'd really like to get rid of the part where I convert the JSON to a `[String: JSON]` just to nil out the properties. I'm wondering what best practice the community suggests, and if it should consider implementing such a feature in the future.\r\n\r\nThanks!"}}
{"actor":{"display_login":"justinmakaila"}}