POJO Stuck

Feb. 9th, 2023 09:18 pm
billroper: (Default)
[personal profile] billroper
When I originally ported our code to Java, it was some years ago. One of the things that I wrote was a fairly robust class to support XML serialization which handled the various types that I wanted to handle as simple calls, burying the translation to and from Strings. It also knows how to detect and avoid duplicating multiple instances of the same object that are in the serialization stream. And it has a SAX-like callback method to allow the classes that it works with to read attributes and contained elements in any order that they are presented.

Overall, it's a nice class.

But Java moves forward and the Jackson libraries now support XML serialization using their own scheme. In this case, you add some simple annotations to the class and now you can read and write an object (Plain Old Java Object, or POJO) belonging to the class in XML as well as JSON.

I spent the last two days adding support for Jackson-enabled objects to my XML serialization library. This was relatively simple, because both my XML serialization library and Jackson's are built on top of StAX, which is a very nice XML streaming system. I had to make a few changes, because I had used the XMLEventReader and Jackson wanted the XMLStreamReader, but that mostly just required me to remove all of the peek() references from my code.

Today, the modified code passed all of the unit tests (and some new tests that I added for the occasion), so you can now read and write Jackson-enabled objects as part of my XML serialization scheme.

It's nice to have a quick win.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

billroper: (Default)
billroper

July 2025

S M T W T F S
   1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 1819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 19th, 2025 09:02 am
Powered by Dreamwidth Studios