Re: [Simple-support] How to serialize an object to this very simple XML (single inline element)?
Brought to you by:
niallg
|
From: Timo R. <tim...@di...> - 2013-04-23 16:41:05
|
Hi everyone, I found the answer myself, I need to use the "@Text" annotation on the "success" property. Best Regards, Timo -----Ursprüngliche Nachricht----- Von: Timo Rumland [mailto:tim...@di...] Gesendet: Dienstag, 23. April 2013 18:32 An: sim...@li... Betreff: [Simple-support] How to serialize an object to this very simple XML (single inline element)? Hello everyone, my goal is to serialize an object to this very simple XML: -------------------- <abc:response xmlns:abc="http://mynamespace.com/abc">true</abc:response> -------------------- I used this class: -------------------- @Root @Default @Namespace( prefix = "abc", reference = "http://mynamespace.com/abc" ) public static class Response { private Boolean success = true; // Property accessor here [...] } -------------------- With this serializer: -------------------- Format format = new Format( 0, null ); // 'null' to avoid the XML header Serializer serializer = new Persister( format ); -------------------- And I get this (wrong) result: -------------------- <abc:response xmlns:r2mds=" http://mynamespace.com/abc"> <success>true</success> </abc:response> -------------------- So the only difference (that matters) is, that the "true" is wrapped by the "<success>" element. Is it in any way possible to avoid the "<success>" element and put the "true" value inline, to get the desired result (see first example)? Thanks a lot for your help! Best Regards, Timo ---------------------------------------------------------------------------- -- Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |