How to serialize a Map<String, String> using Simple XML?

旧时模样 提交于 2019-12-01 18:31:59

问题


How would you go about serialising a Map using simple XML so that it looks something like:

<elem foo="value">key</elem>

Instead of the normal

<elem foo="key">value</elem>

(The map is one to many, and since this will be edited by humans, I wanted it to be clearer.)

[EDIT]: Doesn't Fix.


回答1:


Have you tried something like:

@ElementMap(entry="property", value="value", attribute=true, inline=true)
private Map<String, String> map;

or some combination, i.e. to use the other attributes of the @ElementMap annotation too?



来源:https://stackoverflow.com/questions/3353500/how-to-serialize-a-mapstring-string-using-simple-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!