{"action":"opened","issue":{"url":"https://api.github.com/repos/marchah/json-mapper-json/issues/19","repository_url":"https://api.github.com/repos/marchah/json-mapper-json","labels_url":"https://api.github.com/repos/marchah/json-mapper-json/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/marchah/json-mapper-json/issues/19/comments","events_url":"https://api.github.com/repos/marchah/json-mapper-json/issues/19/events","html_url":"https://github.com/marchah/json-mapper-json/issues/19","id":312279926,"number":19,"title":"[Bug] Throw wrong error with formatting and key word `$root` and undefined value","user":{"login":"xcatliu","id":5453359,"avatar_url":"https://avatars0.githubusercontent.com/u/5453359?v=4","gravatar_id":"","url":"https://api.github.com/users/xcatliu","html_url":"https://github.com/xcatliu","followers_url":"https://api.github.com/users/xcatliu/followers","following_url":"https://api.github.com/users/xcatliu/following{/other_user}","gists_url":"https://api.github.com/users/xcatliu/gists{/gist_id}","starred_url":"https://api.github.com/users/xcatliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xcatliu/subscriptions","organizations_url":"https://api.github.com/users/xcatliu/orgs","repos_url":"https://api.github.com/users/xcatliu/repos","events_url":"https://api.github.com/users/xcatliu/events{/privacy}","received_events_url":"https://api.github.com/users/xcatliu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-08T07:13:58Z","updated_at":"2018-04-08T07:13:58Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```js\r\njsonMapper.then({\r\n  field1: {\r\n    field2: {\r\n      field3: 'value',\r\n    },\r\n  },\r\n}, {\r\n  'new_field1': {\r\n    path: '$root.field1',\r\n    formatting: (field1) => {\r\n      return field1.field2.field4;\r\n    }\r\n  },\r\n}).catch((e) => {\r\n  console.error(e);\r\n});\r\n```\r\n\r\nShould throw error\r\n\r\n```js\r\nTypeError: Cannot read property 'field4' of undefined\r\n```\r\n\r\nBut got\r\n\r\n```js\r\nTypeError: Cannot read property 'field2' of undefined\r\n```"}}
{"actor":{"display_login":"xcatliu"}}