Allow the usage of JSON for Elixir 1.18+#844
Conversation
whatyouhide
left a comment
There was a problem hiding this comment.
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
JSONif on Elixir 1.18+, no configuration (after all, we'll eventually drop:json_librarynow that JSON is in stdlib) + warn if:json_libraryis configured. This also means we don't need to switch toencode!anddecode!, we know which lib we're using. - Use the configured
:json_libraryif 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/1function, which impacts the usage of this library.In order to match the kernel implementation, this PR changes the interface from
decode/1andencode/1todecode!/1andencode!/1.This PR does not change the default library (keeping it as
Jason).It will use
JSONfor tests if the Elixir version is 1.18+. The CI tests both libraries.