{"action":"opened","issue":{"url":"https://api.github.com/repos/utahiosmac/Marshal/issues/133","repository_url":"https://api.github.com/repos/utahiosmac/Marshal","labels_url":"https://api.github.com/repos/utahiosmac/Marshal/issues/133/labels{/name}","comments_url":"https://api.github.com/repos/utahiosmac/Marshal/issues/133/comments","events_url":"https://api.github.com/repos/utahiosmac/Marshal/issues/133/events","html_url":"https://github.com/utahiosmac/Marshal/issues/133","id":374484727,"node_id":"MDU6SXNzdWUzNzQ0ODQ3Mjc=","number":133,"title":"SIGABRT when accessing dot separated keypath on non-object fileds","user":{"login":"Sega-Zero","id":2203199,"node_id":"MDQ6VXNlcjIyMDMxOTk=","avatar_url":"https://avatars1.githubusercontent.com/u/2203199?v=4","gravatar_id":"","url":"https://api.github.com/users/Sega-Zero","html_url":"https://github.com/Sega-Zero","followers_url":"https://api.github.com/users/Sega-Zero/followers","following_url":"https://api.github.com/users/Sega-Zero/following{/other_user}","gists_url":"https://api.github.com/users/Sega-Zero/gists{/gist_id}","starred_url":"https://api.github.com/users/Sega-Zero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sega-Zero/subscriptions","organizations_url":"https://api.github.com/users/Sega-Zero/orgs","repos_url":"https://api.github.com/users/Sega-Zero/repos","events_url":"https://api.github.com/users/Sega-Zero/events{/privacy}","received_events_url":"https://api.github.com/users/Sega-Zero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-26T17:50:25Z","updated_at":"2018-10-26T17:50:25Z","closed_at":null,"author_association":"NONE","body":"This construction\r\n```swift\r\nextension NSDictionary: MarshaledObject {\r\n    public func any(for key: KeyType) throws -> Any {\r\n        guard let value: Any = self.value(forKeyPath: key.stringValue) else {\r\n            throw MarshalError.keyNotFound(key: key)\r\n        }\r\n```\r\n\r\nis not really safe to use in case when we try to access a field that is not an object.\r\nSay, we have this json:\r\n```json\r\n{\r\n\t\"contact_id\": \"123456\",\r\n\t\"type\": 0,\r\n\t\"avatar\": \"\",\r\n\t\"org\": {\"name\": \"name\"},\r\n}\r\n```\r\n\r\nAnd this model:\r\n```swift\r\nstruct Test: Unmarshaling {\r\n    let identifier: String\r\n    let orgName: String?\r\n    init(object: MarshaledObject) throws {\r\n        self.identifier = try object.value(for: \"contact_id\")\r\n        self.name = try object.value(for: \"org.org_name\")\r\n    }\r\n}\r\n```\r\n\r\nSometimes, by accident, server may return this json:\r\n```json\r\n{\r\n\t\"contact_id\": \"123456\",\r\n\t\"type\": 0,\r\n\t\"avatar\": \"\",\r\n\t\"org\": \"\",\r\n}\r\n```\r\n\r\nIn that case I get SIGABRT:\r\n![marshaldictionary swift 2018-10-26 20-45-39](https://user-images.githubusercontent.com/2203199/47583508-6044a780-d960-11e8-833b-cf060c3a88c4.jpg)\r\n\r\nRight now I have to workaround it by implementing a private struct for org field and map to it first, but it would be better if the code above would just return nil without crashing"}}
{"actor":{"display_login":"Sega-Zero"}}