java - @Element annotation needs to be added on all fields? -
if have class 20 fields, need add @element annotation on each of them? there way tell simple-framework take all?
no, can use @default
annotation:
the
default
annotation used specify fields or methods should serialized in default manner. allows objects fields or properties serialized without need annotate them.
in addition @default
can still use custom annotations @element
:
@root @default public static class example { private int value = 3; private string string = "abc"; @element(name = "some-custom-name") private string customstring = "custom"; // ... }
output:
<example> <value>3</value> <string>abc</string> <some-custom-name>custom</some-custom-name> </example>
Comments
Post a Comment