|
>NOTE: This approach seems to work nicely for Map<String,String>. But if values I attached a new version of the JsonMapAdapter class, which tries to address the An important point for mapped notation is not to forget to call the xml2JsonNs Please test if it works for you and provide input about discovered problems. TODO: Right now, unmarshalling would only work for a value of class C, if at romixlev, your solution looks like a good starting point! I ran into an issue though: Element keyValueElement = doc.createElement(entry.getKey().toString()); entity.getKey().toString() produces e.g. "4", which is not a valid xml entity and causes: SEVERE: org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. Any idea how to fix this? If I change the line to the following, it works but output is obviously wrong: Element keyValueElement = doc.createElement("x" + entry.getKey().toString()); All in all, XML isn't Json and having to jump through it ends up being a real pain :/ @mike_meessen I ran into the very same issue, it is impossible to use a string key starting with a number. In case of UUIDs it works only when the UUID start with a letter. From what I understand it's impossible to solve the issue except by removing JAXB from the equation. That's a real pitty that JAX-RS 1 cannot produce simple json like that. I don't know about JAX-RS 2 but if it's still based on JAXB the problem will remain. I hope someone can prove us wrong and tell us "there is a way and this is ...". Regards |
|||||||||||||||||||||||||||||||||||||||||||||||
Created an attachment (id=131)
XML type adapter implementation for producing JSON friendly format from java.util.Map