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

Avoiding the circular reference stop #679

Closed
RikvanderLinde opened this issue Aug 7, 2018 · 1 comment
Closed

Avoiding the circular reference stop #679

RikvanderLinde opened this issue Aug 7, 2018 · 1 comment

Comments

@RikvanderLinde
Copy link

I have been trying to find a way to get in between the moment where the serializer finds something it already serialized, and the moment where it decides to return null.

My data has a lot of references to itself, and a null destroys the linking. Hence when it finds a circular reference I want to do a simple Entity check, and if so serialize only the ID. That way the data structure remains intact, since an property could be null.

I have tried looking in the visitors, and the "XmlSerializationVisitor" has something called "isCircularRef"

This guided me towards the "SerializationContext" where it seems to keep track of the objects in its "$visitingSet"

This is private, and gives me no option remove objects. I also cant extend it, since the visitor checks for the "SerializationContext"
The other problem is that I am looking for the JSON visitor...

At this point I feel like something is wrong, as I need to edit so much files only slightly.

TL:DR

Turn this:

A

[
    {
    "id": "00001",
    "B": {
        "id": "00002",
        "A": null,
        "C": {
            "id": "00003",
        },
]

Into this:

A

[
    {
    "id": "00001",
    "B": {
        "id": "00002",
        "A": {
            "id": "00001",
        },
        "C": {
            "id": "00003",
        },
]

@RikvanderLinde
Copy link
Author

Wrong repo

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

1 participant