Use the built-in JSON library#6481
Conversation
| end | ||
|
|
||
| assert_raise json_error, | ||
| ~r/invalid byte 111 at position \(byte offset\) 0|unexpected byte at position 0: 0x6F \("o"\)/, fn -> |
|
Looks good to me! But if we actually change new projects to use JSON, we'll also need to bump the minimum version we set to Elixir 1.18, see Lines 12 to 20 in 9fc21c6 I wonder if we should postpone this change to a future Phoenix 1.9? @josevalim |
josevalim
left a comment
There was a problem hiding this comment.
Yes, v1.9 material for sure. But it looks good. We can probably assign a v1.9 milestone and merge it once we finally branch v1.8 out. I don’t think it is worth branching out though, as I dont think there is anything beyond this PR for now?
I don't think there's anything else I can add to this PR. Thank you everyone for looking into this! 🙇 |

Address #6461
The changes set the built-in JSON library as a default JSON library.
The idea is to check whether the built-in JSON library is present and use it if so:
Correct me if I'm wrong, but I think a naive check of whether the library is present during compilation time should work, as it's a built-in library.
What I'm not sure about is whether such a move results in a breaking change.
It could be a breaking change for projects that don't specify the
json_libraryand use@derive Jason.Encoderon structures passed toPhoenix.Controller.json/2. That sounds pretty niche, especially given that the template project includes:Also, I'm specifically leaving the
jasondependency in place for pre-27 OTP versions.Please let me know what you think and whether the changes make sense. In other words, maybe it would be better to stick with
Jasonuntil Phoenix requires OTP 28.Similar discussions / changes:
Use Jason instead of Poison for json encoding by chrismccord #2734phoenixframework/phoenix
Investigate using Jason instead of Poison #2693phoenixframework/phoenix
Use JSON instead of Jason by kubosuke #234felt/geo