How do I prevent an infinite loop when serializing a 3-node reference in Java into JSON? -
in spring mvc application have 3 classes - content, category, , document - interrelated , must serialized json, when doing cause infinite loop. relationship such:
content -> list<category> -> list<document> -> list<content> -> (etc.)
where category property of content, etc. i'm trying serialize reference ends @ list (so content.categories.documents exposed view), not finding way go it. annotating jackson's @jsonmanagedreference , @jsonbackreference won't work because of these fields annotated such other relationships. not sure how go other possibly constructing model specific relevant view.
edit: if helps, error got "org.springframework.http.converter.httpmessagenotwritableexception: not write json: infinite recursion (stackoverflowerror)" followed trace of reference chain.
perhaps have @ @jsonidentityinfo
annotation, can used handling cyclic dependencies (this entry mentions it)? won't work collection
s (alas), work pojos contained in collections, arrays , maps.
Comments
Post a Comment