Support native JSON module
Since Elixir 1.18 there is a native JSON module, so new projects don't need Jason and many don't have it. This pull request updates the error tracker so:
- Jason is an optional dependency as the error tracker can work without it
- We try to use the user-defined JSON library (just like we did before) but if none is defined we default to the native
JSONmodule for Elixir 1.18 and newer. On older versions we still default toJasonjust like we did before. - We use the
encode_to_iodata!function which is the most performant and provided by both libraries. - The
JSONmodule can't pretty print likeJasondoes. Instead we are now pretty printing in the client using JSON.stringify which is widely available across all browsers.
There should not be any user-facing changes. Users will still see the JSON context formatted just like they did before but now the ErrorTracker works well on Elixir 1.18 and newer projects that don't include Jason. We also don't force it for such projects as a native alternative exists.
Closes #131
I've just run mix assets.build, not sure why there are so many changes in the app.js file 🤔
@crbelaus any update on this one? Do you need help, by any chance?
I'd love to see this PR going through :)
@crbelaus any update on this one? Do you need help, by any chance?
If someone can help testing this under Elixir 1.18 it would be great, just to confirm that things are working as expected without Jason.
Hey, I've tested it now. Sorry for the delay. It works as expected.