2

I need help. How to convert this complex object List<Map<List<Set<Integer>>, String>> to XML? I've been trying Xstream, JAXB and Jackson XML (there was the best result but it still not working in the right way). The main problems are that this is not a Pojo and tags must comply with XML Naming Rules. Maybe I missed something in these libs. And, this enormous object is a constant, I can't change it.

    List<Map<List<Set<Integer>>, String>> mylist = new Main().generateLayeredObject(3); //3 - is size of all collections 

    XmlMapper xmlMapper = new XmlMapper();
    xmlMapper.setDefaultUseWrapper(false);
    xmlMapper.writeValue(new File("simple_bean.xml"), mylist);

This is the result (Integer - random numbers, String - random UUID). It's just for test

<ArrayList>
<item>
    <[[434739, 345896, 107710], [173471, 148399, 956177], [877420, 58433, 251738]]>f56e7b8a-ccdb-4947-9bc7-f54614acfd12</[[434739, 345896, 107710], [173471, 148399, 956177], [877420, 58433, 251738]]>
    <[[504012, 632997, 493307], [33204, 419998, 339516], [504962, 673459, 71580]]>c7cb8114-e3e0-4800-a8b5-2297c0e85623</[[504012, 632997, 493307], [33204, 419998, 339516], [504962, 673459, 71580]]>
    <[[725097, 212505, 194206], [29459, 672466, 85407], [254593, 826008, 4991]]>5abff991-26d2-4e81-a033-449ba1966115</[[725097, 212505, 194206], [29459, 672466, 85407], [254593, 826008, 4991]]>
</item>
<item>
    <[[42406, 947545, 709364], [777471, 545741, 442491], [222049, 679980, 59304]]>902c1927-50e5-4eec-a01f-4b9f432e9d97</[[42406, 947545, 709364], [777471, 545741, 442491], [222049, 679980, 59304]]>
    <[[600585, 519155, 491663], [265492, 277746, 195533], [145425, 331358, 459180]]>fdd977d3-e44f-4d09-a4d7-ccd9cd914970</[[600585, 519155, 491663], [265492, 277746, 195533], [145425, 331358, 459180]]>
    <[[263684, 737677, 801589], [195047, 318546, 197980], [442833, 996598, 378968]]>ad2a5eeb-ba0f-473b-980e-c30b52c31a48</[[263684, 737677, 801589], [195047, 318546, 197980], [442833, 996598, 378968]]>
</item>
<item>
    <[[59826, 602227, 85180], [412341, 49433, 773943], [316915, 746023, 412746]]>e8700b91-90ba-4497-906d-5bc6099b979b</[[59826, 602227, 85180], [412341, 49433, 773943], [316915, 746023, 412746]]>
    <[[888393, 499266, 441003], [985500, 899481, 256030], [712271, 472545, 799626]]>016a5fc9-4ed2-4a0d-b2ef-b9efca7ffb16</[[888393, 499266, 441003], [985500, 899481, 256030], [712271, 472545, 799626]]>
    <[[511594, 66334, 322123], [366710, 46953, 699044], [364150, 748952, 505101]]>e1cad848-2497-454f-88ff-80bc633460e5</[[511594, 66334, 322123], [366710, 46953, 699044], [364150, 748952, 505101]]>
</item>

Cosmic
  • 21
  • 3
  • If this is your resulting output XML, and you have the choice to design it, why not split down your items to additional elements like ``, ... – Glains Mar 26 '19 at 12:28
  • Thank you) Your suggestion made me think about parsing the output, but this seems like a very cumbersome solution. I want to figure out how to make the output right at once. So that each tag takes a name from the name of the collection (like this: ...) – Cosmic Mar 26 '19 at 12:41

0 Answers0