[Proposal] JSON (OTP 27) adoption

29 views
Skip to first unread message

Egor Mikhnevich

unread,
Sep 15, 2025, 11:36:41 AMSep 15
to elixir-ecto
Hi all,

So far, `postgrex` uses the `Jason` library by default. Yet, some libraries (like `geo`) start to rely on the new built-in `JSON` library.

Given that the built-in `JSON` library is going to replace the `Jason` library, I wonder how the adoption strategy for `postgrex` could look like.

Considering the need to support the before 27 OTP versions, maybe a possible way would be to check if the JSON library is available dynamically.

Here's the point where `postgrex` picks its `json_library`. And how it could look like with `Code.ensure_loaded?`:

      Keyword.get_lazy(opts, :json, fn ->
        case Application.fetch_env(:postgrex, :json_library) do
          {:ok, library} ->
            library

          :error ->
            if Code.ensure_loaded?(JSON) do
              JSON
            else
              Jason
            end
        end
      end)

One of the downsides is it's still a breaking change, as probably all rely on having `Jason` there by default. I'm struggling to find a way to do that without breaking changes, though.

Please let me know if you have any thoughts regarding the JSON adoption.

Kind regards,
Egor

Jon Rowe

unread,
Sep 17, 2025, 7:39:21 AMSep 17
to Elixir Ecto
I think switching to JSON would be a good idea. A new version would take care of the "breaking" aspect, even maybe go to `1.x.x` if concerned.  I believe support for earlier OTP should continue though.

Cheers
Jon
--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages