Serializing a class as String (or other type)

48 views
Skip to first unread message

Sven Zethelius

unread,
Mar 31, 2017, 12:06:52 AM3/31/17
to protostuff

Using the RuntimeSchema framework where the schema is determined by the object, is there any supported way to change a Java object's serialization from a complex type to a simple string type?  As an example, JAXB supports XmlJavaAdapter to change the serialized type of a field.

In this case I want to take a complex type (org.joda.time.DateTime) and have it marshal as it's ISO String representation ("2016-03-30T12:38:00.000-07:00").

David Yu

unread,
Mar 31, 2017, 12:09:02 AM3/31/17
to protostuff
On Fri, Mar 31, 2017 at 3:40 AM, Sven Zethelius <szet...@gmail.com> wrote:

Using the RuntimeSchema framework where the schema is determined by the object, is there any supported way to change a Java object's serialization from a complex type to a simple string type?  As an example, JAXB supports XmlJavaAdapter to change the serialized type of a field.

In this case I want to take a complex type (org.joda.time.DateTime) and have it marshal as it's ISO String representation ("2016-03-30T12:38:00.000-07:00").
Sure.
Simply register a delegate for that type.

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
- David Yu
Reply all
Reply to author
Forward
0 new messages