1- # Jason
1+ # JasonVendored
22
33A blazing fast JSON parser and generator in pure Elixir.
44
55The parser and generator are at least twice as fast as other Elixir/Erlang libraries
66(most notably ` Poison ` ).
77The performance is comparable to ` jiffy ` , which is implemented in C as a NIF.
8- Jason is usually only twice as slow.
8+ JasonVendored is usually only twice as slow.
99
1010Both parser and generator fully conform to
1111[ RFC 8259] ( https://tools.ietf.org/html/rfc8259 ) and
2626## Basic Usage
2727
2828``` elixir
29- iex (1 )> Jason .encode! (%{" age" => 44 , " name" => " Steve Irwin" , " nationality" => " Australian" })
29+ iex (1 )> JasonVendored .encode! (%{" age" => 44 , " name" => " Steve Irwin" , " nationality" => " Australian" })
3030" {\" age\" :44,\" name\" :\" Steve Irwin\" ,\" nationality\" :\" Australian\" }"
3131
32- iex (2 )> Jason .decode! (~s( {"age":44,"name":"Steve Irwin","nationality":"Australian"}) )
32+ iex (2 )> JasonVendored .decode! (~s( {"age":44,"name":"Steve Irwin","nationality":"Australian"}) )
3333%{" age" => 44 , " name" => " Steve Irwin" , " nationality" => " Australian" }
3434```
3535
@@ -39,17 +39,17 @@ Full documentation can be found at [https://hexdocs.pm/jason](https://hexdocs.pm
3939
4040### Postgrex
4141
42- Versions starting at 0.14.0 use ` Jason ` by default. For earlier versions, please refer to
42+ Versions starting at 0.14.0 use ` JasonVendored ` by default. For earlier versions, please refer to
4343[ previous versions of this document] ( https://github.com/michalmuskala/jason/tree/v1.1.2#postgrex ) .
4444
4545### Ecto
4646
47- Versions starting at 3.0.0 use ` Jason ` by default. For earlier versions, please refer to
47+ Versions starting at 3.0.0 use ` JasonVendored ` by default. For earlier versions, please refer to
4848[ previous versions of this document] ( https://github.com/michalmuskala/jason/tree/v1.1.2#ecto ) .
4949
5050### Plug (and Phoenix)
5151
52- Phoenix starting at 1.4.0 uses ` Jason ` by default. For earlier versions, please refer to
52+ Phoenix starting at 1.4.0 uses ` JasonVendored ` by default. For earlier versions, please refer to
5353[ previous versions of this document] ( https://github.com/michalmuskala/jason/tree/v1.1.2#plug-and-phoenix ) .
5454
5555### Absinthe
@@ -60,12 +60,12 @@ You need to pass the `:json_codec` option to `Absinthe.Plug`
6060# When called directly:
6161plug Absinthe .Plug ,
6262 schema: MyApp .Schema ,
63- json_codec: Jason
63+ json_codec: JasonVendored
6464
6565# When used in phoenix router:
6666forward " /api" ,
6767 to: Absinthe .Plug ,
68- init_opts: [schema: MyApp .Schema , json_codec: Jason ]
68+ init_opts: [schema: MyApp .Schema , json_codec: JasonVendored ]
6969```
7070
7171## Benchmarks
@@ -85,24 +85,24 @@ A HTML report of the benchmarks (after their execution) can be found in
8585
8686## Differences to Poison
8787
88- Jason has a couple feature differences compared to Poison.
88+ JasonVendored has a couple feature differences compared to Poison.
8989
90- * Jason follows the JSON spec more strictly, for example it does not allow
90+ * JasonVendored follows the JSON spec more strictly, for example it does not allow
9191 unescaped newline characters in JSON strings - e.g. ` "\"\n\"" ` will
9292 produce a decoding error.
9393 * no support for decoding into data structures (the ` as: ` option).
9494 * no built-in encoders for ` MapSet ` , ` Range ` and ` Stream ` .
9595 * no support for encoding arbitrary structs - explicit implementation
96- of the ` Jason .Encoder` protocol is always required.
96+ of the ` JasonVendored .Encoder` protocol is always required.
9797 * different pretty-printing customisation options (default ` pretty: true ` works the same)
9898
9999If you require encoders for any of the unsupported collection types, I suggest
100100adding the needed implementations directly to your project:
101101
102102``` elixir
103- defimpl Jason .Encoder , for: [MapSet , Range , Stream ] do
103+ defimpl JasonVendored .Encoder , for: [MapSet , Range , Stream ] do
104104 def encode (struct, opts) do
105- Jason .Encode .list (Enum .to_list (struct), opts)
105+ JasonVendored .Encode .list (Enum .to_list (struct), opts)
106106 end
107107end
108108```
@@ -112,7 +112,7 @@ if you own the struct, you can derive the implementation specifying
112112which fields should be encoded to JSON:
113113
114114``` elixir
115- @derive {Jason .Encoder , only: [.... ]}
115+ @derive {JasonVendored .Encoder , only: [.... ]}
116116defstruct # ...
117117```
118118
@@ -121,21 +121,21 @@ used carefully to avoid accidentally leaking private information
121121when new fields are added:
122122
123123``` elixir
124- @derive Jason .Encoder
124+ @derive JasonVendored .Encoder
125125defstruct # ...
126126```
127127
128128Finally, if you don't own the struct you want to encode to JSON,
129129you may use ` Protocol.derive/3 ` placed outside of any module:
130130
131131``` elixir
132- Protocol .derive (Jason .Encoder , NameOfTheStruct , only: [.. .])
133- Protocol .derive (Jason .Encoder , NameOfTheStruct )
132+ Protocol .derive (JasonVendored .Encoder , NameOfTheStruct , only: [.. .])
133+ Protocol .derive (JasonVendored .Encoder , NameOfTheStruct )
134134```
135135
136136## License
137137
138- Jason is released under the Apache License 2.0 - see the [ LICENSE] ( LICENSE ) file.
138+ JasonVendored is released under the Apache License 2.0 - see the [ LICENSE] ( LICENSE ) file.
139139
140140Some elements of tests and benchmarks have their origins in the
141141[ Poison library] ( https://github.com/devinus/poison ) and were initially licensed under [ CC0-1.0] ( https://creativecommons.org/publicdomain/zero/1.0/ ) .
0 commit comments