Skip to content

Commit f1c10fa

Browse files
committed
make the vendored name shorter
1 parent 198fc86 commit f1c10fa

24 files changed

+165
-165
lines changed

README.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# JasonVendored
1+
# JasonV
22

33
A blazing fast JSON parser and generator in pure Elixir.
44

55
The parser and generator are at least twice as fast as other Elixir/Erlang libraries
66
(most notably `Poison`).
77
The performance is comparable to `jiffy`, which is implemented in C as a NIF.
8-
JasonVendored is usually only twice as slow.
8+
JasonV is usually only twice as slow.
99

1010
Both parser and generator fully conform to
1111
[RFC 8259](https://tools.ietf.org/html/rfc8259) and
@@ -26,10 +26,10 @@ end
2626
## Basic Usage
2727

2828
``` elixir
29-
iex(1)> JasonVendored.encode!(%{"age" => 44, "name" => "Steve Irwin", "nationality" => "Australian"})
29+
iex(1)> JasonV.encode!(%{"age" => 44, "name" => "Steve Irwin", "nationality" => "Australian"})
3030
"{\"age\":44,\"name\":\"Steve Irwin\",\"nationality\":\"Australian\"}"
3131

32-
iex(2)> JasonVendored.decode!(~s({"age":44,"name":"Steve Irwin","nationality":"Australian"}))
32+
iex(2)> JasonV.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 `JasonVendored` by default. For earlier versions, please refer to
42+
Versions starting at 0.14.0 use `JasonV` 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 `JasonVendored` by default. For earlier versions, please refer to
47+
Versions starting at 3.0.0 use `JasonV` 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 `JasonVendored` by default. For earlier versions, please refer to
52+
Phoenix starting at 1.4.0 uses `JasonV` 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:
6161
plug Absinthe.Plug,
6262
schema: MyApp.Schema,
63-
json_codec: JasonVendored
63+
json_codec: JasonV
6464

6565
# When used in phoenix router:
6666
forward "/api",
6767
to: Absinthe.Plug,
68-
init_opts: [schema: MyApp.Schema, json_codec: JasonVendored]
68+
init_opts: [schema: MyApp.Schema, json_codec: JasonV]
6969
```
7070

7171
## Benchmarks
@@ -85,15 +85,15 @@ A HTML report of the benchmarks (after their execution) can be found in
8585

8686
## Differences to Poison
8787

88-
JasonVendored has a couple feature differences compared to Poison.
88+
JasonV has a couple feature differences compared to Poison.
8989

90-
* JasonVendored follows the JSON spec more strictly, for example it does not allow
90+
* JasonV 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 `JasonVendored.Encoder` protocol is always required.
96+
of the `JasonV.Encoder` protocol is always required.
9797
* different pretty-printing customisation options (default `pretty: true` works the same)
9898

9999
### Encoders
@@ -102,9 +102,9 @@ If you require encoders for any of the unsupported collection types, I suggest
102102
adding the needed implementations directly to your project:
103103

104104
```elixir
105-
defimpl JasonVendored.Encoder, for: [MapSet, Range, Stream] do
105+
defimpl JasonV.Encoder, for: [MapSet, Range, Stream] do
106106
def encode(struct, opts) do
107-
JasonVendored.Encode.list(Enum.to_list(struct), opts)
107+
JasonV.Encode.list(Enum.to_list(struct), opts)
108108
end
109109
end
110110
```
@@ -114,7 +114,7 @@ if you own the struct, you can derive the implementation specifying
114114
which fields should be encoded to JSON:
115115

116116
```elixir
117-
@derive {JasonVendored.Encoder, only: [....]}
117+
@derive {JasonV.Encoder, only: [....]}
118118
defstruct # ...
119119
```
120120

@@ -123,16 +123,16 @@ used carefully to avoid accidentally leaking private information
123123
when new fields are added:
124124

125125
```elixir
126-
@derive JasonVendored.Encoder
126+
@derive JasonV.Encoder
127127
defstruct # ...
128128
```
129129

130130
Finally, if you don't own the struct you want to encode to JSON,
131131
you may use `Protocol.derive/3` placed outside of any module:
132132

133133
```elixir
134-
Protocol.derive(JasonVendored.Encoder, NameOfTheStruct, only: [...])
135-
Protocol.derive(JasonVendored.Encoder, NameOfTheStruct)
134+
Protocol.derive(JasonV.Encoder, NameOfTheStruct, only: [...])
135+
Protocol.derive(JasonV.Encoder, NameOfTheStruct)
136136
```
137137

138138
## Injecting an already encoded JSON inside a to-be-encoded structure
@@ -151,7 +151,7 @@ or if it is already provided by another system (e.g. `jsonb_agg` with Postgres).
151151

152152
## License
153153

154-
JasonVendored is released under the Apache License 2.0 - see the [LICENSE](LICENSE) file.
154+
JasonV is released under the Apache License 2.0 - see the [LICENSE](LICENSE) file.
155155

156156
Some elements of tests and benchmarks have their origins in the
157157
[Poison library](https://github.com/devinus/poison) and were initially licensed under [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/).

bench/decode.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
decode_jobs = %{
2-
"JasonVendored" => fn {json, _} -> JasonVendored.decode!(json) end,
2+
"JasonV" => fn {json, _} -> JasonV.decode!(json) end,
33
"Poison" => fn {json, _} -> Poison.decode!(json) end,
44
"JSX" => fn {json, _} -> JSX.decode!(json, [:strict]) end,
55
"Tiny" => fn {json, _} -> Tiny.decode!(json) end,
@@ -30,7 +30,7 @@ read_data = fn name ->
3030
|> String.trim("-")
3131

3232
json = File.read!(Path.expand("data/#{file}.json", __DIR__))
33-
etf = :erlang.term_to_binary(JasonVendored.decode!(json))
33+
etf = :erlang.term_to_binary(JasonV.decode!(json))
3434

3535
{json, etf}
3636
end

bench/encode.exs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
encode_jobs = %{
2-
"JasonVendored" => &JasonVendored.encode_to_iodata!/1,
3-
"JasonVendored strict" => &JasonVendored.encode_to_iodata!(&1, maps: :strict),
2+
"JasonV" => &JasonV.encode_to_iodata!/1,
3+
"JasonV strict" => &JasonV.encode_to_iodata!(&1, maps: :strict),
44
"Poison" => &Poison.encode_to_iodata!/1,
55
"JSX" => &JSX.encode!/1,
66
"Tiny" => &Tiny.encode!/1,
@@ -41,7 +41,7 @@ Benchee.run(encode_jobs,
4141
for name <- encode_inputs, into: %{} do
4242
name
4343
|> read_data.()
44-
|> JasonVendored.decode!()
44+
|> JasonV.decode!()
4545
|> (&{name, &1}).()
4646
end,
4747
formatters: [

bench/mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule JasonVendoredBench.MixProject do
1+
defmodule JasonVBench.MixProject do
22
use Mix.Project
33

44
def project do

lib/codegen.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
defmodule JasonVendored.Codegen do
1+
defmodule JasonV.Codegen do
22
@moduledoc false
33

4-
alias JasonVendored.{Encode, EncodeError}
4+
alias JasonV.{Encode, EncodeError}
55

66
def jump_table(ranges, default) do
77
ranges

lib/decoder.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule JasonVendored.DecodeError do
1+
defmodule JasonV.DecodeError do
22
@type t :: %__MODULE__{position: integer, data: String.t()}
33

44
defexception [:position, :token, :data]
@@ -25,12 +25,12 @@ defmodule JasonVendored.DecodeError do
2525
end
2626
end
2727

28-
defmodule JasonVendored.Decoder do
28+
defmodule JasonV.Decoder do
2929
@moduledoc false
3030

3131
import Bitwise
3232

33-
alias JasonVendored.{DecodeError, Codegen}
33+
alias JasonV.{DecodeError, Codegen}
3434

3535
import Codegen, only: [bytecase: 2, bytecase: 3]
3636
import Record
@@ -77,7 +77,7 @@ defmodule JasonVendored.Decoder do
7777
defp string_decode_function(%{strings: :reference}), do: & &1
7878

7979
defp object_decode_function(%{objects: :maps}), do: &:maps.from_list/1
80-
defp object_decode_function(%{objects: :ordered_objects}), do: &JasonVendored.OrderedObject.new(:lists.reverse(&1))
80+
defp object_decode_function(%{objects: :ordered_objects}), do: &JasonV.OrderedObject.new(:lists.reverse(&1))
8181

8282
defp float_decode_function(%{floats: :native}) do
8383
fn string, token, skip ->

lib/encode.ex

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule JasonVendored.EncodeError do
1+
defmodule JasonV.EncodeError do
22
defexception [:message]
33

44
@type t :: %__MODULE__{message: String.t()}
@@ -12,14 +12,14 @@ defmodule JasonVendored.EncodeError do
1212
end
1313
end
1414

15-
defmodule JasonVendored.Encode do
15+
defmodule JasonV.Encode do
1616
@moduledoc """
1717
Utilities for encoding elixir values to JSON.
1818
"""
1919

2020
import Bitwise
2121

22-
alias JasonVendored.{Codegen, EncodeError, Encoder, Fragment, OrderedObject}
22+
alias JasonV.{Codegen, EncodeError, Encoder, Fragment, OrderedObject}
2323

2424
@typep escape :: (String.t(), String.t(), integer -> iodata)
2525
@typep encode_map :: (map, escape, encode_map -> iodata)
@@ -41,7 +41,7 @@ defmodule JasonVendored.Encode do
4141
:throw, %EncodeError{} = e ->
4242
{:error, e}
4343

44-
:error, %Protocol.UndefinedError{protocol: JasonVendored.Encoder} = e ->
44+
:error, %Protocol.UndefinedError{protocol: JasonV.Encoder} = e ->
4545
{:error, e}
4646
end
4747
end
@@ -66,7 +66,7 @@ defmodule JasonVendored.Encode do
6666
end
6767

6868
@doc """
69-
Equivalent to calling the `JasonVendored.Encoder.encode/2` protocol function.
69+
Equivalent to calling the `JasonV.Encoder.encode/2` protocol function.
7070
7171
Slightly more efficient for built-in types because of the internal dispatching.
7272
"""

0 commit comments

Comments
 (0)