{"action":"created","issue":{"url":"https://api.github.com/repos/marklogic/entity-services/issues/80","repository_url":"https://api.github.com/repos/marklogic/entity-services","labels_url":"https://api.github.com/repos/marklogic/entity-services/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/marklogic/entity-services/issues/80/comments","events_url":"https://api.github.com/repos/marklogic/entity-services/issues/80/events","html_url":"https://github.com/marklogic/entity-services/issues/80","id":166145680,"number":80,"title":"Investigate the special case of serialization entity instance to JSON, with array of  one item","user":{"login":"grechaw","id":382672,"avatar_url":"https://avatars.githubusercontent.com/u/382672?v=3","gravatar_id":"","url":"https://api.github.com/users/grechaw","html_url":"https://github.com/grechaw","followers_url":"https://api.github.com/users/grechaw/followers","following_url":"https://api.github.com/users/grechaw/following{/other_user}","gists_url":"https://api.github.com/users/grechaw/gists{/gist_id}","starred_url":"https://api.github.com/users/grechaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grechaw/subscriptions","organizations_url":"https://api.github.com/users/grechaw/orgs","repos_url":"https://api.github.com/users/grechaw/repos","events_url":"https://api.github.com/users/grechaw/events{/privacy}","received_events_url":"https://api.github.com/users/grechaw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/marklogic/entity-services/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/marklogic/entity-services/labels/minor","name":"minor","color":"e99695"},{"url":"https://api.github.com/repos/marklogic/entity-services/labels/verify","name":"verify","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"grechaw","id":382672,"avatar_url":"https://avatars.githubusercontent.com/u/382672?v=3","gravatar_id":"","url":"https://api.github.com/users/grechaw","html_url":"https://github.com/grechaw","followers_url":"https://api.github.com/users/grechaw/followers","following_url":"https://api.github.com/users/grechaw/following{/other_user}","gists_url":"https://api.github.com/users/grechaw/gists{/gist_id}","starred_url":"https://api.github.com/users/grechaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grechaw/subscriptions","organizations_url":"https://api.github.com/users/grechaw/orgs","repos_url":"https://api.github.com/users/grechaw/repos","events_url":"https://api.github.com/users/grechaw/events{/privacy}","received_events_url":"https://api.github.com/users/grechaw/received_events","type":"User","site_admin":false},"assignees":[{"login":"grechaw","id":382672,"avatar_url":"https://avatars.githubusercontent.com/u/382672?v=3","gravatar_id":"","url":"https://api.github.com/users/grechaw","html_url":"https://github.com/grechaw","followers_url":"https://api.github.com/users/grechaw/followers","following_url":"https://api.github.com/users/grechaw/following{/other_user}","gists_url":"https://api.github.com/users/grechaw/gists{/gist_id}","starred_url":"https://api.github.com/users/grechaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grechaw/subscriptions","organizations_url":"https://api.github.com/users/grechaw/orgs","repos_url":"https://api.github.com/users/grechaw/repos","events_url":"https://api.github.com/users/grechaw/events{/privacy}","received_events_url":"https://api.github.com/users/grechaw/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/marklogic/entity-services/milestones/4","html_url":"https://github.com/marklogic/entity-services/milestones/9.0-ea4","labels_url":"https://api.github.com/repos/marklogic/entity-services/milestones/4/labels","id":1890817,"number":4,"title":"9.0-ea4","description":"The release of entity services code corresponding with MarkLogic Server 9.0-EA4","creator":{"login":"grechaw","id":382672,"avatar_url":"https://avatars.githubusercontent.com/u/382672?v=3","gravatar_id":"","url":"https://api.github.com/users/grechaw","html_url":"https://github.com/grechaw","followers_url":"https://api.github.com/users/grechaw/followers","following_url":"https://api.github.com/users/grechaw/following{/other_user}","gists_url":"https://api.github.com/users/grechaw/gists{/gist_id}","starred_url":"https://api.github.com/users/grechaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grechaw/subscriptions","organizations_url":"https://api.github.com/users/grechaw/orgs","repos_url":"https://api.github.com/users/grechaw/repos","events_url":"https://api.github.com/users/grechaw/events{/privacy}","received_events_url":"https://api.github.com/users/grechaw/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":5,"state":"open","created_at":"2016-07-18T22:42:37Z","updated_at":"2016-09-30T15:36:08Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-07-18T17:17:39Z","updated_at":"2016-09-30T23:42:28Z","closed_at":null,"body":"When an entity instance stores a propery, it uses XML elements and sequence semantics to do so.  That means that the instance data model cannot tell when it is representing an array, if there is only one item in the array.\r\n\r\nWe need to investigate this issue and perhaps correct it.  An attribute in the XML data could solve the issue."},"comment":{"url":"https://api.github.com/repos/marklogic/entity-services/issues/comments/250876328","html_url":"https://github.com/marklogic/entity-services/issues/80#issuecomment-250876328","issue_url":"https://api.github.com/repos/marklogic/entity-services/issues/80","id":250876328,"user":{"login":"grechaw","id":382672,"avatar_url":"https://avatars.githubusercontent.com/u/382672?v=3","gravatar_id":"","url":"https://api.github.com/users/grechaw","html_url":"https://github.com/grechaw","followers_url":"https://api.github.com/users/grechaw/followers","following_url":"https://api.github.com/users/grechaw/following{/other_user}","gists_url":"https://api.github.com/users/grechaw/gists{/gist_id}","starred_url":"https://api.github.com/users/grechaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grechaw/subscriptions","organizations_url":"https://api.github.com/users/grechaw/orgs","repos_url":"https://api.github.com/users/grechaw/repos","events_url":"https://api.github.com/users/grechaw/events{/privacy}","received_events_url":"https://api.github.com/users/grechaw/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T23:42:28Z","updated_at":"2016-09-30T23:42:28Z","body":"I've got an implementation of this working.  I'll pitch it to the WG Monday and see whether or not to move foward with the change.\r\n\r\nIn essence, I've added an attribute to the default for `es:instance-to-canonical-xml`.  If a property is of type array, then the XML has an attribute datatype=\"array\" added to it\r\n\r\n```\r\n<Order>\r\n    <orderId>10248</orderId>\r\n    <orderDate>1995-07-05</orderDate>\r\n    <hasOrderDetails datatype=\"array\">\r\n        <OrderDetails>\r\n            <quantity>40</quantity>\r\n            <productName>Capris</productName>\r\n        </OrderDetails>\r\n    </hasOrderDetails>\r\n</Order>\r\n```\r\n\r\nThis attribute can inform es:instance-json-from-document(), which then serializes this item property as an array rather than as a single item.\r\n\r\nUp to this point we do not have a way to ensure that the output in JSON has an array.\r\n\r\nShould work for empty arrays too, for required properties.\r\n\r\n```\r\n<Order>\r\n    <orderId>10248</orderId>\r\n    <orderDate>1995-07-05</orderDate>\r\n    <hasOrderDetails datatype=\"array\" />\r\n</Order>\r\n```"}}
{"actor":{"display_login":"grechaw"}}