First things first, I’m no asking for a solution but a way to think.
I got some data that I need to serialize to check out later… I know how to do it.. but the fields names are the problem…
The data structure contains:
Name of the Field
CoordX
CoordY
Value
(There are like.. 20 different fields. I need to check a biiiggggg string log…)
I could use a single String[][] or several Strings[] … as I said.. the problem is how it appears on the XML…
If I do a single arraylist multidimensional -> [][] I got this
<teste>
<string-array>
<string>fieldName</string>
<string>x</string>
<string>y</string>
<string>value</string>
</string-array>
<string-array>
<string>fieldName</string>
<string>x</string>
<string>y</string>
<string>value</string>
</string-array>
</teste>
And if I do a single string[] I can put the name of the String as the field name
<Fieldname>
<string>X</string>
<string>y</string>
<string>Value</string>
</Fieldname>
I saw that normal alias is for ALL fields (@XStreamImplicit(itemFieldName=”part”)) and that don’t solve my problem..
It could be worthless if on the other side when I do deserialization, check the log by line and no by field (I know line 1 is field name, line 2 is x..etc)..
So.. what do you guys think?
I usually design serialization depending on the contents of my “fields”. Say that your name and value fields are relatively small, you could serialize them as
of course, if value is long, then you don’t want to serialize it as attribute, but as a regular field value like so:
You can achieve this using XStream like so:
where you define your Container and Field like so:
The program gives this output:
Hope this helps.