Skip to content
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

Bring back Phoenix compatibility #206

Closed
wants to merge 2 commits into from
Closed

Bring back Phoenix compatibility #206

wants to merge 2 commits into from

Conversation

erszcz
Copy link

@erszcz erszcz commented Mar 17, 2022

Hi! Dropping encode_to_iodata!/1 has lead to losing compatibility with Phoenix as can be seen with phoenixframework/phoenix#4727. If this PR gets accepted it will unblock phoenixframework/phoenix#4728 which brings that compatibility back.

@RudolfMan
Copy link
Contributor

PR's been open since Aug 2021 😭 #197

@erszcz
Copy link
Author

erszcz commented Mar 18, 2022

Thanks, @RudolfMan!
Well, I can only hope this PR is heard as another voice in the case 🤞

@erszcz
Copy link
Author

erszcz commented Jun 27, 2023

This is still a problem, but I'm cleaning up some of my repos, so I'll be closing this PR. If one needs to use Poison with Phoenix, Postgrex, or PhoenixSwagger, then a shim module like this one might be handy:

defmodule MyApp.Poison do
  @moduledoc false

  defdelegate decode(iodata, options \\ %{}), to: Poison
  defdelegate decode!(value, options \\ %{}), to: Poison

  defdelegate encode(value, options \\ %{}), to: Poison
  defdelegate encode!(value, options \\ %{}), to: Poison

  @doc """
  Encodes a value to JSON, returning an iodata.

  Equivalent to `encode!(value, iodata: true)`.

  Prefer `encode!/1`.
  This function only exists for compatibility with Phoenix, Postgres, or PhoenixSwagger. 
  """
  def encode_to_iodata!(value) do
    Poison.encode!(value, iodata: true)
  end
end

Then the only remaining bit is the config:

$ rg json_lib
config/config.exs
9:config :phoenix, :json_library, MyApp.Poison
10:config :postgrex, :json_library, MyApp.Poison
22:config :phoenix_swagger, json_library: MyApp.Poison

@erszcz erszcz closed this Jun 27, 2023
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Added `Date.Range` encoding
* Allow `:as` decode option to be a function
* Added a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improved performance

Breaking Changes:

* Removed deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
devinus added a commit that referenced this pull request Jun 9, 2024
Features:

* Support Erlang 27 and Elixir 1.17
* Reintroduce `Poison.encode_to_iodata!/1` for Phoenix compatibility
* Make `:html_safe` encode option follow OWASP recommended HTML
  escaping
* Add `Date.Range` encoding
* Allow `:as` decode option to be a function
* Add a CHANGELOG

Bug Fixes:

* Stop double decoding structs
* Fix various typespecs
* Correctly encode some UTF-8 surrogate pairs

Performance Improvements:

* Significantly improve performance

Breaking Changes:

* Remove deprecated `HashSet` encoding
* Minimum supported versions are now Erlang 24 and Elixir 1.12

Closes #105, #172, #191, #194, #199, #206, #207, #214, #217, #222.
This was referenced Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants