@@ -39,56 +39,18 @@ Full documentation can be found at [https://hexdocs.pm/jason](https://hexdocs.pm
39
39
40
40
### Postgrex
41
41
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 ) .
43
44
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 ` .
53
45
### Ecto
54
46
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 ) .
68
49
69
50
### Plug (and Phoenix)
70
51
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 ) .
92
54
93
55
### Absinthe
94
56
0 commit comments