Skip to content

Commit 8c0701f

Browse files
committed
Jason is now a common default, remove usage instructions
1 parent e44decf commit 8c0701f

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

README.md

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,56 +39,18 @@ Full documentation can be found at [https://hexdocs.pm/jason](https://hexdocs.pm
3939

4040
### Postgrex
4141

42-
You need to define a custom "types" module in an `.ex` file, somewhere in `lib`:
42+
Versions starting at 0.14.0 use `Jason` by default. For earlier versions, please refer to
43+
[previous versions of this document](https://github.com/michalmuskala/jason/tree/v1.1.2#postgrex).
4344

44-
```elixir
45-
Postgrex.Types.define(MyApp.PostgresTypes, [], json: Jason)
46-
47-
## If using with ecto, you also need to pass ecto default extensions:
48-
49-
Postgrex.Types.define(MyApp.PostgresTypes, [] ++ Ecto.Adapters.Postgres.extensions(), json: Jason)
50-
```
51-
52-
Then you can use the module, by passing it to `Postgrex.start_link`.
5345
### Ecto
5446

55-
To replicate fully the current behaviour of `Poison` when used in Ecto applications,
56-
you need to configure `Jason` to be the default encoder of the `postgrex` library, in `config/config.exs`:
57-
58-
```elixir
59-
config :postgrex, :json_library, Jason
60-
```
61-
62-
Additionally, when using PostgreSQL, you need to define a custom types module as described
63-
above, and configure your repo to use it (in either `config/config.exs` or `config/<env>.exs`):
64-
65-
```elixir
66-
config :my_app, MyApp.Repo, types: MyApp.PostgresTypes
67-
```
47+
Versions starting at 3.0.0 use `Jason` by default. For earlier versions, please refer to
48+
[previous versions of this document](https://github.com/michalmuskala/jason/tree/v1.1.2#ecto).
6849

6950
### Plug (and Phoenix)
7051

71-
First, you need to configure `Plug.Parsers` to use `Jason` for parsing JSON. You need to find,
72-
where you're plugging the `Plug.Parsers` plug (in case of Phoenix, it will be in the
73-
Endpoint module) and configure it in your endpoint module (`lib/app_web/endpoint.ex`),
74-
for example:
75-
76-
```elixir
77-
plug Plug.Parsers,
78-
parsers: [:urlencoded, :multipart, :json],
79-
pass: ["*/*"],
80-
json_decoder: Jason
81-
```
82-
83-
Additionally, for Phoenix, you need to configure the "encoder" in `config/config.exs`:
84-
85-
```elixir
86-
config :phoenix, :format_encoders,
87-
json: Jason
88-
```
89-
90-
A custom JSON encoder for Phoenix channels is unfortunately a bit more involved,
91-
you can find code for a custom serializer and how to use it [in here](https://gist.github.com/michalmuskala/d5fabcd26be2befdfb72b72e0b0f2797).
52+
Phoenix starting at 1.4.0 uses `Jason` by default. For earlier versions, please refer to
53+
[previous versions of this document](https://github.com/michalmuskala/jason/tree/v1.1.2#plug-and-phoenix).
9254

9355
### Absinthe
9456

0 commit comments

Comments
 (0)