-
Notifications
You must be signed in to change notification settings - Fork 219
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
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PR's been open since Aug 2021 😭 #197 |
Thanks, @RudolfMan! |
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 |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.