{"action":"closed","issue":{"url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/178","labels_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/178/comments","events_url":"https://api.github.com/repos/Leonidas-from-XIV/node-xml2js/issues/178/events","html_url":"https://github.com/Leonidas-from-XIV/node-xml2js/issues/178","id":58175917,"number":178,"title":"Writing CDATA failed on non-array properties","user":{"login":"hail2u","id":68940,"avatar_url":"https://avatars.githubusercontent.com/u/68940?v=3","gravatar_id":"","url":"https://api.github.com/users/hail2u","html_url":"https://github.com/hail2u","followers_url":"https://api.github.com/users/hail2u/followers","following_url":"https://api.github.com/users/hail2u/following{/other_user}","gists_url":"https://api.github.com/users/hail2u/gists{/gist_id}","starred_url":"https://api.github.com/users/hail2u/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hail2u/subscriptions","organizations_url":"https://api.github.com/users/hail2u/orgs","repos_url":"https://api.github.com/users/hail2u/repos","events_url":"https://api.github.com/users/hail2u/events{/privacy}","received_events_url":"https://api.github.com/users/hail2u/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-19T07:24:16Z","updated_at":"2015-03-25T23:37:20Z","closed_at":"2015-03-25T23:37:20Z","body":"`Builder({cdata:true})` introduced in v0.4.5 does not work properly on a sub property that is not Array.\r\n\r\nTest code:\r\n\r\n```javascript\r\nvar xml2js = require('xml2js');\r\n\r\nconsole.log(new xml2js.Builder({\r\n  cdata: true\r\n}).buildObject({\r\n  'foo': {\r\n    'bar': 'baz & qux'\r\n  }\r\n}));\r\n```\r\n\r\nOutputs:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n<foo>\r\n   <bar>baz &amp; qux</bar>\r\n</foo>\r\n```\r\n\r\nShould be:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n<foo>\r\n   <bar><![CDATA[baz & qux]]></bar>\r\n</foo>\r\n```\r\n\r\nI think calling `wrapCDATA` at [Case #5](https://github.com/Leonidas-from-XIV/node-xml2js/blob/208dff5784dfed5951d4bebe9c4071935cfabbdc/src/xml2js.coffee#L161-L163) is also required for writing CDATA properly."}}