{"action":"created","issue":{"url":"https://api.github.com/repos/javaee/glassfish/issues/22378","repository_url":"https://api.github.com/repos/javaee/glassfish","labels_url":"https://api.github.com/repos/javaee/glassfish/issues/22378/labels{/name}","comments_url":"https://api.github.com/repos/javaee/glassfish/issues/22378/comments","events_url":"https://api.github.com/repos/javaee/glassfish/issues/22378/events","html_url":"https://github.com/javaee/glassfish/issues/22378","id":280721224,"node_id":"MDU6SXNzdWUyODA3MjEyMjQ=","number":22378,"title":"Names in Json data returned by Web Service are not defined ones.","user":{"login":"Mararsh","id":11675544,"node_id":"MDQ6VXNlcjExNjc1NTQ0","avatar_url":"https://avatars0.githubusercontent.com/u/11675544?v=4","gravatar_id":"","url":"https://api.github.com/users/Mararsh","html_url":"https://github.com/Mararsh","followers_url":"https://api.github.com/users/Mararsh/followers","following_url":"https://api.github.com/users/Mararsh/following{/other_user}","gists_url":"https://api.github.com/users/Mararsh/gists{/gist_id}","starred_url":"https://api.github.com/users/Mararsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mararsh/subscriptions","organizations_url":"https://api.github.com/users/Mararsh/orgs","repos_url":"https://api.github.com/users/Mararsh/repos","events_url":"https://api.github.com/users/Mararsh/events{/privacy}","received_events_url":"https://api.github.com/users/Mararsh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-09T13:53:20Z","updated_at":"2018-09-17T20:38:04Z","closed_at":null,"author_association":"NONE","body":"\"@XmlElement(name =xxxx )\" doe not work for Json data returned by Web service\r\n\r\n## Environment Details\r\n* GlassFish Version (and build number): 5.0\r\n* JDK version: 1.8.0_151\r\n* OS: Windows 10\r\n* Database: MySQL 5.7\r\n\r\n## Problem Description\r\nWith GlassFish 4.1.*, we define objects with annotations like \"@XmlElement(name =xxxx )\" to make web services return data of both XML format and JSON format(JAXB). This way is simple and works well.\r\nAfter update to GlassFish 5, Json data returned by web services become unexpected, which makes our client apps fail to work.  \r\nThe problem is that the names in the Json data are changed: They are not the ones defined in \"@XmlElement(name =xxxx )\",  but something else.  \r\n\r\nIn following example,  Json data picks \"isValid\" as data name but not \"is_valid\":\r\n```\r\n    @XmlElement(name = \"is_valid\")   \r\n    private boolean isValid;\r\n```\r\n\r\nI made a special example to show the problem clearly. The code is not standard but is to make issue exposed.\r\n\r\nA field \"isValidXXX\" is defined as:  \r\n\r\n```\r\n@XmlRootElement(**name = \"Terminal\"**)\r\n@XmlAccessorType(XmlAccessType.FIELD)\r\npublic class Terminal {\r\n\r\n\t....\r\n    @XmlElement(name = \"is_valid_yyy\")   \r\n    private boolean isValidXXX;\r\n\t....\r\n\t\r\n    public boolean isIsValid_zZZ() {\r\n        return isValidXXX;\r\n    }\r\n\r\n    public void setIsValidVVV(boolean isValid) {\r\n        this.isValidXXX = isValid;\r\n    }\r\n\r\n```\r\nPlease notice: Differents names of field, element, set method, and get method.\r\n\r\n\r\nA Web Service returns List of this object:\r\n\r\n ```\r\n    @GET\r\n    @Path(\"/gts\")\r\n    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})\r\n    public List<Terminal> getTerminals(@Context HttpServletRequest request,\r\n            @QueryParam(\"t\") String terminals,\r\n            @QueryParam(\"r\") String operate) {\r\n\t....\t\t\r\n```\r\n\r\n\r\nThen XML format of its return is like this:\r\n\r\n`<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><terminals><Terminal><register_number>0166763</register_number><is_valid_yyy>false</is_valid_yyy><valid_start>0</valid_start><valid_end>0</valid_end><last_status_time>1512825274725</last_status_time><last_x>118.70149</last_x><last_y>32.16198</last_y><last_z>-1.0</last_z><last_speed>0.0</last_speed><last_direction>174</last_direction><last_location_time>1479694189000</last_location_time><create_time>0</create_time><last_status><dataid>223</dataid><terminal>0166763</terminal><status_type>出围栏警报</status_type><record_x>118.70149</record_x><record_y>32.16198</record_y><record_z>-1.0</record_z><record_time>1510897110000</record_time><fence>z</fence><email_sent>true</email_sent><message_sent>false</message_sent><feedback_sent>false</feedback_sent><cleared>false</cleared><cleared_time>0</cleared_time><last_record_time>1512825274725</last_record_time><repeats>55</repeats></last_status></Terminal></terminals>\r\n`\r\nSo XML picks the correct name \"is_valid_yyy\".\r\n\r\n\r\nBut Json format of same link is like this:\r\n\r\n`[{\"createTime\":0,\"isValid_zZZ\":false,\"lastDirection\":\"174\",\"lastLocationTime\":1479694189000,\"lastSpeed\":0.0,\"lastStatus\":{\"cleared\":false,\"clearedTime\":0,\"dataid\":223,\"emailSent\":true,\"feedbackSent\":false,\"fence\":\"z\",\"lastRecordTime\":1512825274725,\"messageSent\":false,\"recordTime\":1510897110000,\"recordX\":118.70149,\"recordY\":32.16198,\"recordZ\":-1.0,\"repeats\":55,\"statusType\":\"出围栏警报\",\"terminal\":\"0166763\"},\"lastStatusTime\":1512825274725,\"lastX\":118.70149,\"lastY\":32.16198,\"lastZ\":-1.0,\"registerNumber\":\"0166763\",\"validEnd\":0,\"validStart\":0}]`\r\n\r\nYou can see: Json picks the name based on the get method name \"isValid_zZZ\".\r\n"},"comment":{"url":"https://api.github.com/repos/javaee/glassfish/issues/comments/422162382","html_url":"https://github.com/javaee/glassfish/issues/22378#issuecomment-422162382","issue_url":"https://api.github.com/repos/javaee/glassfish/issues/22378","id":422162382,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMjE2MjM4Mg==","user":{"login":"glassfishrobot","id":6104758,"node_id":"MDQ6VXNlcjYxMDQ3NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6104758?v=4","gravatar_id":"","url":"https://api.github.com/users/glassfishrobot","html_url":"https://github.com/glassfishrobot","followers_url":"https://api.github.com/users/glassfishrobot/followers","following_url":"https://api.github.com/users/glassfishrobot/following{/other_user}","gists_url":"https://api.github.com/users/glassfishrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/glassfishrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glassfishrobot/subscriptions","organizations_url":"https://api.github.com/users/glassfishrobot/orgs","repos_url":"https://api.github.com/users/glassfishrobot/repos","events_url":"https://api.github.com/users/glassfishrobot/events{/privacy}","received_events_url":"https://api.github.com/users/glassfishrobot/received_events","type":"User","site_admin":false},"created_at":"2018-09-17T20:38:04Z","updated_at":"2018-09-17T20:38:04Z","author_association":"CONTRIBUTOR","body":"**Closing this as this issue is migrated to** https://github.com/eclipse-ee4j/glassfish/issues/22378"}}
{"actor":{"display_login":"glassfishrobot"}}