Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does dsl-json deal with circular dependency? #55

Open
jdorleans opened this issue Jun 14, 2018 · 3 comments
Open

How does dsl-json deal with circular dependency? #55

jdorleans opened this issue Jun 14, 2018 · 3 comments

Comments

@jdorleans
Copy link

jdorleans commented Jun 14, 2018

I'm evaluating dsl-json and considering migrating from jackson. The performance I saw on a few benchmarks seemed very impressive and I'd love to play with it a bit more. However, one of my core needs is to deal with graph ser/deser.

Does the lib provide ways to handle circular dependency out-of-the-box? I couldn't find anything on docs or examples. If so, how does it work? If not, is there any way to solve that?

@zapov
Copy link
Member

zapov commented Jun 14, 2018

It works as long as there are no cycles, in which case it stackoverflows. There are some tests for those: https://github.com/ngs-doo/dsl-json/blob/master/tests-java8/src/test/java/com/dslplatform/json/RecursiveTest.java#L44

It works since codec resolution is done lazily.

@jdorleans
Copy link
Author

@zapov thx for pointing the test class. I'm really looking for the ability to have cycles solve automatically by the lib. Is there any way to specify an object ID so the lib can keep track of what was already serialized and solve the cycle?

@zapov
Copy link
Member

zapov commented Jun 16, 2018

There is nothing built in, but you can build your own. Here is a crude example on how to do it: bc5d20e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants