On Tue, Dec 11, 2018 at 7:04 PM Denis Mouraviev <denis.mourav...@gmail.com> wrote: > > Hello, > > i need to serialize cyclic object graph, i dont own those pojos, so > annotations are not the way to go. > I guess i need to write a custom serializer for that. The problem is there a > lot of different types in that graph. > i will end up with atleast a function for each type like: > > gen.writeStartObject(); > gen.writeStringField("id", value.getId()); > writeFlowers(gen, value.getFlowers()); > gen.writeEndObject(); > > > Is there any way to reuse BeanSerializer with ignores or maybe > BeanPropertyWriter > (i know which fields are bidirectional or cyclic references i can exclude em). > > Or may be there is known serailizer which takes for example yaml > specification and based on that specification > serialized objects?
No, annotations (*) are needed to make Jackson handle cyclic references; either full identity (@JsonIdentityInfo) or parent/child style relationship (@JsonManagedReference / @JsonBackReference) (*) or something exposed through `AnnotationIntrospector` But there are 2 ways to supply annotation information even without types themselves having annotations: 1. Mix-in annotations (associate annotations from different interface/class with target type) 2. Custom `AnnotationIntrospector` that obtains configuration from some other source so you may be able to implement it that way. -+ Tatu +- -- 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.