-
-
Notifications
You must be signed in to change notification settings - Fork 199
Allow the usage of JSON for Elixir 1.18+ #844
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m thinking maybe a better approach for this would be:
- Introduce a private module,
Sentry.JSON
, which would act as a temporary middleman (until we will depend on Elixir 1.18+). - Check the Elixir version when compiling Sentry and
- Use
JSON
if on Elixir 1.18+, no configuration (after all, we'll eventually drop:json_library
now that JSON is in stdlib) + warn if:json_library
is configured. This also means we don't need to switch toencode!
anddecode!
, we know which lib we're using. - Use the configured
:json_library
if on earlier versions.
- Use
Thoughts?
Hi @whatyouhide , applied the suggested changes.
It would be wise to still let developers define custom libraries during this transitioning period. |
Why? I can only think of custom protocols and stuff like that, but maybe that's already enough. |
Just like this library was not ready to use the For example, Some services/libraries require a transition for structs that derive from |
True, but using |
Thank you for the advice. 🙇 Let me know if I need to change or improve something. |
Closing in favor of #845. |
Sadly, the JSON kernel module does not provide the
encode/1
function, which impacts the usage of this library.In order to match the kernel implementation, this PR changes the interface from
decode/1
andencode/1
todecode!/1
andencode!/1
.This PR does not change the default library (keeping it as
Jason
).It will use
JSON
for tests if the Elixir version is 1.18+. The CI tests both libraries.