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

Handle cyclic references in JSON encoding and schema #37

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

alexmojaki
Copy link
Contributor

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

return _array_schema(obj)

if id(obj) in seen:
return {}
Copy link
Contributor

@dmontagu dmontagu Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return {}
return {'x-circular-reference': True}

this way we can render something more nicely in the UI for circular references, rather than having it just look like a normal string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this for now because it could make the overall schema significantly larger if the data consists only of JSON values which don't need a schema. This can be added if we actually decide to spend time on rendering in the UI.

Copy link
Contributor

@dmontagu dmontagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I don't know how much overhead this adds. Presumably we could do something in rust that would be faster, but I guess we probably don't want any native dependencies, so this makes sense to me.

Copy link

cloudflare-pages bot commented Apr 30, 2024

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 33f5348
Status: ✅  Deploy successful!
Preview URL: https://441c61ac.logfire-docs.pages.dev
Branch Preview URL: https://alex-recursive-json.logfire-docs.pages.dev

View logs

@alexmojaki alexmojaki enabled auto-merge (squash) April 30, 2024 09:40
@alexmojaki alexmojaki merged commit 7d76ed6 into main Apr 30, 2024
11 checks passed
@alexmojaki alexmojaki deleted the alex/recursive-json branch April 30, 2024 09:42
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

Successfully merging this pull request may close these issues.

None yet

2 participants