4
donuts
4y

TLDR: RTFM...

My dad (taught me how to code when I was a kid) was stuck serializing a Java enum/class to XML.... The enum wasn't just a list of string values but more like a Map(String,Object>.

He tried to annotate it with XMLEnum but the moment I saw this enum, I'm thinking that's unlikely to work.... Mapping all that to just a string?

He tried annotating the Fields in it using XMLAttribute but clearly wasnt working...

Also he use XMLEnumValue but from his test run I could clearly see it just replaced whatever the enum value would've been with some fixed String...

Me: Did you read the documentation or when the javadocs?

Dad: no, I don't like reading documentation and the samples didn't work.

I haven't done XML Serialization for years thought did use JSON and my first instinct was... You need a TypeAdapter to convert the enum to a serializable class.

So I do some Googling, read the docs then just played around with the code, figured out how to serialize a class and also how to implement XmlTypeAdapter.... 20 mins ...

Text him back with screenshots and basically:

See it's not that hard if you actually read up on the javadocs and realized ur enum is more like a class so probably the simple way won't work...

Comments
  • 2
    Student should be better than teacher. That is called progress.
  • 0
    @mr-user there's also the willingness to admit ur wrong and try a different route when u hit a dead end rather then keep trying to break/hack thru a concrete wall
Add Comment