{"action":"created","issue":{"url":"https://api.github.com/repos/joelvh/json2json/issues/9","repository_url":"https://api.github.com/repos/joelvh/json2json","labels_url":"https://api.github.com/repos/joelvh/json2json/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/joelvh/json2json/issues/9/comments","events_url":"https://api.github.com/repos/joelvh/json2json/issues/9/events","html_url":"https://github.com/joelvh/json2json/pull/9","id":46779563,"number":9,"title":"Add forceArray config option","user":{"login":"mikejpeters","id":3334654,"avatar_url":"https://avatars.githubusercontent.com/u/3334654?v=3","gravatar_id":"","url":"https://api.github.com/users/mikejpeters","html_url":"https://github.com/mikejpeters","followers_url":"https://api.github.com/users/mikejpeters/followers","following_url":"https://api.github.com/users/mikejpeters/following{/other_user}","gists_url":"https://api.github.com/users/mikejpeters/gists{/gist_id}","starred_url":"https://api.github.com/users/mikejpeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikejpeters/subscriptions","organizations_url":"https://api.github.com/users/mikejpeters/orgs","repos_url":"https://api.github.com/users/mikejpeters/repos","events_url":"https://api.github.com/users/mikejpeters/events{/privacy}","received_events_url":"https://api.github.com/users/mikejpeters/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-10-24T20:21:40Z","updated_at":"2016-02-10T15:54:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joelvh/json2json/pulls/9","html_url":"https://github.com/joelvh/json2json/pull/9","diff_url":"https://github.com/joelvh/json2json/pull/9.diff","patch_url":"https://github.com/joelvh/json2json/pull/9.patch"},"body":"Add `forceArray` config option that, when set to `true`, will wrap the node in an array if it is a map.  Useful when transforming JSON that was converted from XML, in which case a node that may normally contain multiple items will be converted to a JSON map if it only contains a single item.\r\n\r\nFor example, an XML to JSON converter will typically convert the XML:\r\n\r\n```xml\r\n<breakfast_menu>\r\n  <food>\r\n    <name>Belgian Waffles</name>\r\n    <price>$5.95</price>\r\n  </food>\r\n</breakfast_menu>\r\n```\r\n\r\nto the JSON:\r\n\r\n```json\r\n{\r\n  \"breakfast_menu\": {\r\n    \"food\": {\r\n      \"name\": \"Belgian Waffles\",\r\n      \"price\": \"$5.95\"\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nThe `forceArray` config option can be used to rectify this:\r\n\r\n```js\r\nnew json2json.ObjectTemplate({\r\n  path: 'breakfast_menu.food',\r\n  all: true,\r\n  forceArray: true\r\n}).transform(json)\r\n```\r\n\r\n```[ { name: 'Belgian Waffles', price: '$5.95' } ]```\r\n"},"comment":{"url":"https://api.github.com/repos/joelvh/json2json/issues/comments/182442695","html_url":"https://github.com/joelvh/json2json/pull/9#issuecomment-182442695","issue_url":"https://api.github.com/repos/joelvh/json2json/issues/9","id":182442695,"user":{"login":"mikejpeters","id":3334654,"avatar_url":"https://avatars.githubusercontent.com/u/3334654?v=3","gravatar_id":"","url":"https://api.github.com/users/mikejpeters","html_url":"https://github.com/mikejpeters","followers_url":"https://api.github.com/users/mikejpeters/followers","following_url":"https://api.github.com/users/mikejpeters/following{/other_user}","gists_url":"https://api.github.com/users/mikejpeters/gists{/gist_id}","starred_url":"https://api.github.com/users/mikejpeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikejpeters/subscriptions","organizations_url":"https://api.github.com/users/mikejpeters/orgs","repos_url":"https://api.github.com/users/mikejpeters/repos","events_url":"https://api.github.com/users/mikejpeters/events{/privacy}","received_events_url":"https://api.github.com/users/mikejpeters/received_events","type":"User","site_admin":false},"created_at":"2016-02-10T15:54:47Z","updated_at":"2016-02-10T15:54:47Z","body":"Hey sorry I forgot about this! I'll try to make the changes this week!"}}