Considering that ja_serializer
uses Poison
while phoenix 1.4.4
uses Jason
, does ja_serializer
work with phoenix 1.4.4
?
ja_serializer
only uses Poison
for tests. You configure what it uses by saying how plug should encode/decode the json-api mime type. All you need to do is follow the instructions in this section and replace Poison with Jason.
Thanks for the reply @blatyo!
I tried changing the line
config :phoenix, :format_encoders, "json-api": Poison
to:
config :phoenix, :format_encoders, "json-api": Jason
but it results in the following:
Compiling 10 files (.ex)
Generated library_api app
** (Mix) Could not start application poison: could not find application file: poison.app
which leads me to assume this must not be the only line that I should change to use Jason
instead of Poison
What is your Elixir version? We had some bugs around optional dependencies, and that may have triggered it. You can also run mix app.tree
and see what is bringing poison as a dependency.
Hello @josevalim!!!
here is the result of my mix app.tree
:
library_api
|-- elixir
|-- logger
| `-- elixir
|-- runtime_tools
|-- gettext
| |-- elixir
| `-- logger
|-- jason
| `-- elixir
|-- comeonin
| |-- elixir
| `-- logger
|-- bcrypt_elixir
| |-- elixir
| |-- logger
| |-- crypto
| `-- comeonin
|-- phoenix_pubsub
| |-- elixir
| |-- logger
| `-- crypto
|-- postgrex
| |-- elixir
| |-- logger
| |-- crypto
| |-- connection
| | `-- elixir
| |-- decimal
| | `-- elixir
| `-- db_connection
| |-- elixir
| |-- logger
| `-- connection
|-- ecto_sql
| |-- elixir
| |-- logger
| |-- telemetry
| |-- db_connection
| `-- ecto
| |-- elixir
| |-- logger
| |-- crypto
| `-- decimal
|-- plug_cowboy
| |-- elixir
| |-- logger
| |-- cowboy
| | |-- crypto
| | |-- cowlib
| | | `-- crypto
| | `-- ranch
| | `-- ssl
| | |-- crypto
| | `-- public_key
| | |-- asn1
| | `-- crypto
| `-- plug
| |-- elixir
| |-- logger
| |-- mime
| | |-- elixir
| | `-- logger
| `-- plug_crypto
| |-- elixir
| `-- crypto
|-- phoenix
| |-- elixir
| |-- logger
| |-- eex
| | `-- elixir
| |-- crypto
| |-- phoenix_pubsub
| `-- plug
|-- cors_plug
| |-- elixir
| `-- logger
|-- ja_serializer
| |-- elixir
| |-- logger
| |-- inflex
| | `-- elixir
| |-- plug
** (Mix) could not find application poison
Looks like its the ja_serializer
is the one causing it the way I see the output
elixir -v
:
Erlang/OTP 21 [erts-10.2] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Elixir 1.8.1 (compiled with Erlang/OTP 20)
v1.8.1 @josevalim
Erlang/OTP 21 [erts-10.2] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
Elixir 1.8.1 (compiled with Erlang/OTP 20)
I can’t see Poison anywhere and your Elixir version is good. If you push a small app to GitHub that reproduces it we can take a look.
wait let me re-create it…
You are correct. ja_serializer requires the poison application. They fixed it in this commit but they have not released a new version. I would recommend filing an issue to ask for a new release.
@josevalim, is there some other way that I can get around to making this work for now while the release is still being requested? Can I possibly edit ja_serializer in my deps folder for this?
You can load deps by their github commit.
Thanks @LostKobrakai. is editing the deps directly okay for the moment? quiet a dirty hack for now though but I love to hear your opinion
Loading from git is not a hack, it’s first-class supported by mix
, even has helpers like github: "orgname/projectname"
and such too.
As for editing the deps, it’s fine but it will get reverted by a lot of different actions.