• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to Serialize Maps?

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone help me modify my program below so it will serialize a map to standard output? Sun had documented a bug several years ago concerning the serialization of maps and I am hoping it has been fixed by now.
Thanks,
Siegfried

 
Sheriff
Posts: 27463
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ran that code (with the XML from the comments before it) and it produced this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><demoMaps><datum name="xyz_modified"><value>Insert your sample data here_modified</value></datum><datum name="abc"><value>def</value></datum><map/></demoMaps>



Looks okay to me, except for that empty <map> element at the end. Was that what you were referring to? Is it a problem?

Edit: looking at your code it looks like you were expecting the contents of the map to be serialized as well. At least that's what I would expect. So if that's the bug (you didn't say what this bug was) then it's still there.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It'd be easier if you just said what issue you're having. The code works as-is for me once the command is fixed:That ">" at the beginning of line 2 shouldn't be there.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, the map.

Don't you need @XmlJavaTypeAdapter to do maps?

http://www.caucho.com/resin/doc/jaxb-annotations.xtp#@XmlJavaTypeAdapter
 
Siegfried Heintze
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry -- yup. The map is empty. That is the problem I was hoping was fixed by now. Wow! sun sure is slow at fixing these things.
 
Siegfried Heintze
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to implement the suggested code at http://www.caucho.com/resin/doc/jaxb-annotations.xtp#@XmlJavaTypeAdapter and I need some help.

Can someone help me implement the marshal and unmarshal methods? I'm having trouble understand how class Temp works. Why would marshal return a single temp? Wouldn't it return a java.util.list<Temp>?

Perhaps the problem is that eclipse generated the stub for marshal and unmarshal incorrectly?

Thanks,
Siegfried




 
Siegfried Heintze
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out.

I have a new question now! See my new post.

Thanks,
Siegfried
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic