codecutout / JsonApiSerializer

JsonApiSerializer supports configurationless serializing and deserializing objects into the json:api format (http://jsonapi.org).
MIT License
113 stars 46 forks source link

Prevent stack overflow exceptions from occurring with circular references #114

Closed alex-davies closed 4 years ago

alex-davies commented 4 years ago

Objects were only being added to the included dictionary after completing deserialization. This meant that if relationships were referencing back to the object then they would create new objects.

When we know the contents of the new objects (i.e. Included was processed first) this can cause stackoverflow errors. When two objects reference each other, new objects are continuously created as it resolves each relationship

Fix is to add objects to the included list as soon as they are created, before they process any relationships