java - How to json with circular references? -


i have following class construct creating circular dependency. in general, jackson library should able handle these circular dependencies.

i'm looking way not having use annotations on every class has circularities, somehow configure in objectmapper.

@jsonidentityinfo(generator = objectidgenerators.intsequencegenerator.class, property = "@id") abstract class shape;  class line extends shape {     //a line can connect 2 circles     circle from, to; }  class circle extends shape {     // circle can have many lines connected     list<line> lines; } 

i serialize list, contains both circles , lines:

list<shape> shapes;      objectmapper om = new objectmapper().setdefaulttyping(); 

it possible configure id generation globally on mapper?

no. since not types can have ids (only pojo types, is, collections, maps , arrays out), , since details may vary, there no "default id" setting unlike type ids.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -