If I have to serialize an object that I can not annotate and that contains 
parent-child relationship, such as a *DefaultMutableTreeNode*, I can avoid 
the infinite recursion/stack overflow problem by supplying an 
*ObjectIdGenerator 
*from the *findObjectIdInfo*() method in a subclass of the 
*JacksonAnnotationIntrospector. *The ID value is in the resulting JSON 
object. 

There's an example 
here: 
http://stackoverflow.com/questions/27316485/using-jsonidentityinfo-without-annotations

(In addition, with the *DefaultMutableTreeNode *class I have to supply a 
custom *BeanPropertyWriter *to handle exceptions thrown when serializing 
objects like this. 
See: 
http://stackoverflow.com/questions/35359430/how-to-make-jackson-ignore-properties-if-the-getters-throw-exceptions/35416682)

I have 3 constraints I'm trying to satisfy:

1. I can not annotate objects in various dependent libraries.
2. I can not enumerate ahead-of-time all of the possible objects that have 
parent-child relationships
3. I do not want the virtual ID value from an ObjectIdGenerator in the 
serialized JSON object, although I still need a way to keep track of them.

To satisfy 1 and 2 I was thinking of using an ObjectIdGenerator for all 
objects, regardless of whether they contain parent-child relationships or 
whether I had access to the source files. This would simplify development, 
but are there performance penalties for doing this?

I'm not sure how to proceed with #3. What objects do I need to sub-class in 
order to get this to work? It looks like the actual output is done by the 
*WritableObjectId 
*object, which is returned from the 
*DefaultSerializerProvider.findObjectId()* method. But the *WritableObjectId 
*is declared final so I can't override its *writeAsField()* method. Is 
there another way to do this?

Thanks for your help.



-- 


This message and any attachment are confidential and may be privileged or 
otherwise protected from disclosure. If you are not the intended recipient, 
you must not copy this message or attachment or disclose the contents to 
any other person. If you have received this transmission in error, please 
notify the sender immediately and delete the message and any attachment 
from your system. Merck KGaA, Darmstadt, Germany and any of its 
subsidiaries do not accept liability for any omissions or errors in this 
message which may arise as a result of E-Mail-transmission or for damages 
resulting from any unauthorized changes of the content of this message and 
any attachment thereto. Merck KGaA, Darmstadt, Germany and any of its 
subsidiaries do not guarantee that this message is free of viruses and does 
not accept liability for any damages caused by any virus transmitted 
therewith.

Click http://www.emdgroup.com/disclaimer to access the German, French, 
Spanish and Portuguese versions of this disclaimer.

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

Reply via email to