changed
CHANGELOG.md
|
@@ -1,5 +1,8 @@
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+ ## 1.4.99 (1/26/2025)
|
4
|
+ Branch-By-Abstraction Rescoped as Jason.Uo, :jason_uo
|
5
|
+
|
3
6
|
## 1.5.0-alpha.2 (07.07.2023)
|
4
7
|
|
5
8
|
* Add limit to decoded integer sizes of 1024 digits. This can be changed
|
changed
README.md
|
@@ -19,7 +19,7 @@ in `mix.exs`:
|
19
19
|
|
20
20
|
```elixir
|
21
21
|
def deps do
|
22
|
- [{:jason_uo, "~> 1.4"}]
|
22
|
+ [{:jason, "~> 1.4"}]
|
23
23
|
end
|
24
24
|
```
|
changed
hex_metadata.config
|
@@ -1,7 +1,7 @@
|
1
1
|
{<<"links">>,
|
2
2
|
[{<<"GitHub">>,<<"https://github.com/noizu-labs-scaffolding/jason">>}]}.
|
3
3
|
{<<"name">>,<<"jason_uo">>}.
|
4
|
- {<<"version">>,<<"1.4.98">>}.
|
4
|
+ {<<"version">>,<<"1.4.99">>}.
|
5
5
|
{<<"description">>,
|
6
6
|
<<"A blazing fast JSON parser and generator in pure Elixir.">>}.
|
7
7
|
{<<"elixir">>,<<"~> 1.4">>}.
|
|
@@ -17,6 +17,11 @@
|
17
17
|
{<<"app">>,<<"jason_native">>},
|
18
18
|
{<<"optional">>,true},
|
19
19
|
{<<"requirement">>,<<">= 0.0.0">>},
|
20
|
+ {<<"repository">>,<<"hexpm">>}],
|
21
|
+ [{<<"name">>,<<"jason">>},
|
22
|
+ {<<"app">>,<<"jason">>},
|
23
|
+ {<<"optional">>,true},
|
24
|
+ {<<"requirement">>,<<"~> 1.4">>},
|
20
25
|
{<<"repository">>,<<"hexpm">>}]]}.
|
21
26
|
{<<"files">>,
|
22
27
|
[<<"lib">>,<<"lib/encoder.ex">>,<<"lib/formatter.ex">>,<<"lib/jason.ex">>,
|
changed
lib/codegen.ex
|
@@ -1,7 +1,7 @@
|
1
|
- defmodule Jason.Codegen do
|
1
|
+ defmodule Jason.Uo.Codegen do
|
2
2
|
@moduledoc false
|
3
3
|
|
4
|
- alias Jason.{Encode, EncodeError}
|
4
|
+ alias Jason.Uo.{Encode, EncodeError}
|
5
5
|
|
6
6
|
def jump_table(ranges, default) do
|
7
7
|
ranges
|
changed
lib/decoder.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defmodule Jason.DecodeError do
|
1
|
+ defmodule Jason.Uo.DecodeError do
|
2
2
|
@type t :: %__MODULE__{position: integer, data: String.t}
|
3
3
|
|
4
4
|
defexception [:position, :token, :data]
|
|
@@ -22,12 +22,12 @@ defmodule Jason.DecodeError do
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
- defmodule Jason.Decoder do
|
25
|
+ defmodule Jason.Uo.Decoder do
|
26
26
|
@moduledoc false
|
27
27
|
|
28
28
|
import Bitwise
|
29
29
|
|
30
|
- alias Jason.{DecodeError, Codegen}
|
30
|
+ alias Jason.Uo.{DecodeError, Codegen}
|
31
31
|
|
32
32
|
import Codegen, only: [bytecase: 2, bytecase: 3]
|
33
33
|
import Record
|
|
@@ -73,7 +73,7 @@ defmodule Jason.Decoder do
|
73
73
|
defp string_decode_function(%{strings: :reference}), do: &(&1)
|
74
74
|
|
75
75
|
defp object_decode_function(%{objects: :maps}), do: &:maps.from_list/1
|
76
|
- defp object_decode_function(%{objects: :ordered_objects}), do: &Jason.OrderedObject.new(:lists.reverse(&1))
|
76
|
+ defp object_decode_function(%{objects: :ordered_objects}), do: &Jason.Uo.OrderedObject.new(:lists.reverse(&1))
|
77
77
|
|
78
78
|
defp float_decode_function(%{floats: :native}) do
|
79
79
|
fn string, token, skip ->
|
|
@@ -161,10 +161,10 @@ defmodule Jason.Decoder do
|
161
161
|
end
|
162
162
|
|
163
163
|
if function_exported?(Application, :compile_env, 3) do
|
164
|
- @integer_digit_limit Application.compile_env(:jason_uo, :decoding_integer_digit_limit, 1024)
|
164
|
+ @integer_digit_limit Application.compile_env(:jason_ui, :decoding_integer_digit_limit, 1024)
|
165
165
|
else
|
166
166
|
# use apply to avoid warnings in newer Elixir versions
|
167
|
- @integer_digit_limit apply(Application, :get_env, [:jason_uo, :decoding_integer_digit_limit, 1024])
|
167
|
+ @integer_digit_limit apply(Application, :get_env, [:jason_ui, :decoding_integer_digit_limit, 1024])
|
168
168
|
end
|
169
169
|
|
170
170
|
defp number(<<byte, rest::bits>>, original, skip, stack, decode, len)
|
changed
lib/encode.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defmodule Jason.EncodeError do
|
1
|
+ defmodule Jason.Uo.EncodeError do
|
2
2
|
defexception [:message]
|
3
3
|
|
4
4
|
@type t :: %__MODULE__{message: String.t}
|
|
@@ -11,14 +11,14 @@ defmodule Jason.EncodeError do
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
- defmodule Jason.Encode do
|
14
|
+ defmodule Jason.Uo.Encode do
|
15
15
|
@moduledoc """
|
16
16
|
Utilities for encoding elixir values to JSON.
|
17
17
|
"""
|
18
18
|
|
19
19
|
import Bitwise
|
20
20
|
|
21
|
- alias Jason.{Codegen, EncodeError, Encoder, Fragment, OrderedObject}
|
21
|
+ alias Jason.Uo.{Codegen, EncodeError, Encoder, Fragment, OrderedObject}
|
22
22
|
|
23
23
|
@typep escape :: (String.t -> iodata)
|
24
24
|
@typep encode_map :: (map, escape, encode_map -> iodata)
|
|
@@ -41,7 +41,7 @@ defmodule Jason.Encode do
|
41
41
|
{:error, e}
|
42
42
|
:error, {:invalid_byte, _, _} = e ->
|
43
43
|
{:error, EncodeError.new(e)}
|
44
|
- :error, %Protocol.UndefinedError{protocol: Jason.Encoder} = e ->
|
44
|
+ :error, %Protocol.UndefinedError{protocol: Jason.Uo.Encoder} = e ->
|
45
45
|
{:error, e}
|
46
46
|
end
|
47
47
|
end
|
|
@@ -88,7 +88,7 @@ defmodule Jason.Encode do
|
88
88
|
end
|
89
89
|
|
90
90
|
@doc """
|
91
|
- Equivalent to calling the `Jason.Encoder.encode/2` protocol function.
|
91
|
+ Equivalent to calling the `Jason.Uo.Encoder.encode/2` protocol function.
|
92
92
|
|
93
93
|
Slightly more efficient for built-in types because of the internal dispatching.
|
94
94
|
"""
|
changed
lib/encoder.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defprotocol Jason.Encoder do
|
1
|
+ defprotocol Jason.Uo.Encoder do
|
2
2
|
@moduledoc """
|
3
3
|
Protocol controlling how a value is encoded to JSON.
|
4
4
|
|
|
@@ -21,60 +21,59 @@ defprotocol Jason.Encoder do
|
21
21
|
defstruct [:foo, :bar, :baz]
|
22
22
|
end
|
23
23
|
|
24
|
- If we were to call `@derive Jason.Encoder` just before `defstruct`,
|
24
|
+ If we were to call `@derive Jason.Uo.Encoder` just before `defstruct`,
|
25
25
|
an implementation similar to the following implementation would be generated:
|
26
26
|
|
27
|
- defimpl Jason.Encoder, for: Test do
|
27
|
+ defimpl Jason.Uo.Encoder, for: Test do
|
28
28
|
def encode(value, opts) do
|
29
|
- Jason.Encode.map(Map.take(value, [:foo, :bar, :baz]), opts)
|
29
|
+ Jason.Uo.Encode.map(Map.take(value, [:foo, :bar, :baz]), opts)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
- If we called `@derive {Jason.Encoder, only: [:foo]}`, an implementation
|
33
|
+ If we called `@derive {Jason.Uo.Encoder, only: [:foo]}`, an implementation
|
34
34
|
similar to the following implementation would be generated:
|
35
35
|
|
36
|
- defimpl Jason.Encoder, for: Test do
|
36
|
+ defimpl Jason.Uo.Encoder, for: Test do
|
37
37
|
def encode(value, opts) do
|
38
|
- Jason.Encode.map(Map.take(value, [:foo]), opts)
|
38
|
+ Jason.Uo.Encode.map(Map.take(value, [:foo]), opts)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
- If we called `@derive {Jason.Encoder, except: [:foo]}`, an implementation
|
42
|
+ If we called `@derive {Jason.Uo.Encoder, except: [:foo]}`, an implementation
|
43
43
|
similar to the following implementation would be generated:
|
44
44
|
|
45
|
- defimpl Jason.Encoder, for: Test do
|
45
|
+ defimpl Jason.Uo.Encoder, for: Test do
|
46
46
|
def encode(value, opts) do
|
47
|
- Jason.Encode.map(Map.take(value, [:bar, :baz]), opts)
|
47
|
+ Jason.Uo.Encode.map(Map.take(value, [:bar, :baz]), opts)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
The actually generated implementations are more efficient computing some data
|
52
|
- during compilation similar to the macros from the `Jason.Helpers` module.
|
52
|
+ during compilation similar to the macros from the `Jason.Uo.Helpers` module.
|
53
53
|
|
54
54
|
## Explicit implementation
|
55
55
|
|
56
56
|
If you wish to implement the protocol fully yourself, it is advised to
|
57
|
- use functions from the `Jason.Encode` module to do the actual iodata
|
57
|
+ use functions from the `Jason.Uo.Encode` module to do the actual iodata
|
58
58
|
generation - they are highly optimized and verified to always produce
|
59
59
|
valid JSON.
|
60
60
|
"""
|
61
61
|
|
62
62
|
@type t :: term
|
63
|
- @type opts :: Jason.Encode.opts()
|
64
|
-
|
65
|
- @fallback_to_any true
|
63
|
+ @type opts :: Jason.Uo.Encode.opts()
|
66
64
|
|
67
65
|
@doc """
|
68
66
|
Encodes `value` to JSON.
|
69
67
|
|
70
68
|
The argument `opts` is opaque - it can be passed to various functions in
|
71
|
- `Jason.Encode` (or to the protocol function itself) for encoding values to JSON.
|
69
|
+ `Jason.Uo.Encode` (or to the protocol function itself) for encoding values to JSON.
|
72
70
|
"""
|
73
71
|
@spec encode(t, opts) :: iodata
|
74
72
|
def encode(value, opts)
|
75
73
|
end
|
76
74
|
|
77
|
- defimpl Jason.Encoder, for: Any do
|
75
|
+ defimpl Jason.Uo.Encoder, for: Any do
|
76
|
+
|
78
77
|
defmacro __deriving__(module, struct, opts) do
|
79
78
|
fields = fields_to_encode(struct, opts)
|
80
79
|
kv = Enum.map(fields, &{&1, generated_var(&1)})
|
|
@@ -82,11 +81,11 @@ defimpl Jason.Encoder, for: Any do
|
82
81
|
encode_map = quote(do: encode_map)
|
83
82
|
user_opts = quote(do: user_opts)
|
84
83
|
encode_args = [escape, encode_map, user_opts]
|
85
|
- kv_iodata = Jason.Codegen.build_kv_iodata(kv, encode_args)
|
84
|
+ kv_iodata = Jason.Uo.Codegen.build_kv_iodata(kv, encode_args)
|
86
85
|
|
87
86
|
quote do
|
88
|
- defimpl Jason.Encoder, for: unquote(module) do
|
89
|
- require Jason.Helpers
|
87
|
+ defimpl Jason.Uo.Encoder, for: unquote(module) do
|
88
|
+ require Jason.Uo.Helpers
|
90
89
|
|
91
90
|
def encode(%{unquote_splicing(kv)}, {unquote(escape), unquote(encode_map), user_opts}) do
|
92
91
|
unquote(kv_iodata)
|
|
@@ -108,26 +107,26 @@ defimpl Jason.Encoder, for: Any do
|
108
107
|
protocol: @protocol,
|
109
108
|
value: struct,
|
110
109
|
description: """
|
111
|
- Jason.Encoder protocol must always be explicitly implemented.
|
110
|
+ Jason.Uo.Encoder protocol must always be explicitly implemented.
|
112
111
|
|
113
112
|
If you own the struct, you can derive the implementation specifying \
|
114
113
|
which fields should be encoded to JSON:
|
115
114
|
|
116
|
- @derive {Jason.Encoder, only: [....]}
|
115
|
+ @derive {Jason.Uo.Encoder, only: [....]}
|
117
116
|
defstruct ...
|
118
117
|
|
119
118
|
It is also possible to encode all fields, although this should be \
|
120
119
|
used carefully to avoid accidentally leaking private information \
|
121
120
|
when new fields are added:
|
122
121
|
|
123
|
- @derive Jason.Encoder
|
122
|
+ @derive Jason.Uo.Encoder
|
124
123
|
defstruct ...
|
125
124
|
|
126
125
|
Finally, if you don't own the struct you want to encode to JSON, \
|
127
126
|
you may use Protocol.derive/3 placed outside of any module:
|
128
127
|
|
129
|
- Protocol.derive(Jason.Encoder, NameOfTheStruct, only: [...])
|
130
|
- Protocol.derive(Jason.Encoder, NameOfTheStruct)
|
128
|
+ Protocol.derive(Jason.Uo.Encoder, NameOfTheStruct, only: [...])
|
129
|
+ Protocol.derive(Jason.Uo.Encoder, NameOfTheStruct)
|
131
130
|
"""
|
132
131
|
end
|
133
132
|
|
|
@@ -135,7 +134,7 @@ defimpl Jason.Encoder, for: Any do
|
135
134
|
raise Protocol.UndefinedError,
|
136
135
|
protocol: @protocol,
|
137
136
|
value: value,
|
138
|
- description: "Jason.Encoder protocol must always be explicitly implemented"
|
137
|
+ description: "Jason.Uo.Encoder protocol must always be explicitly implemented"
|
139
138
|
end
|
140
139
|
|
141
140
|
defp fields_to_encode(struct, opts) do
|
|
@@ -173,42 +172,42 @@ defimpl Jason.Encoder, for: Any do
|
173
172
|
end
|
174
173
|
|
175
174
|
# The following implementations are formality - they are already covered
|
176
|
- # by the main encoding mechanism in Jason.Encode, but exist mostly for
|
175
|
+ # by the main encoding mechanism in Jason.Uo.Encode, but exist mostly for
|
177
176
|
# documentation purposes and if anybody had the idea to call the protocol directly.
|
178
177
|
|
179
|
- defimpl Jason.Encoder, for: Atom do
|
178
|
+ defimpl Jason.Uo.Encoder, for: Atom do
|
180
179
|
def encode(atom, opts) do
|
181
|
- Jason.Encode.atom(atom, opts)
|
180
|
+ Jason.Uo.Encode.atom(atom, opts)
|
182
181
|
end
|
183
182
|
end
|
184
183
|
|
185
|
- defimpl Jason.Encoder, for: Integer do
|
184
|
+ defimpl Jason.Uo.Encoder, for: Integer do
|
186
185
|
def encode(integer, _opts) do
|
187
|
- Jason.Encode.integer(integer)
|
186
|
+ Jason.Uo.Encode.integer(integer)
|
188
187
|
end
|
189
188
|
end
|
190
189
|
|
191
|
- defimpl Jason.Encoder, for: Float do
|
190
|
+ defimpl Jason.Uo.Encoder, for: Float do
|
192
191
|
def encode(float, _opts) do
|
193
|
- Jason.Encode.float(float)
|
192
|
+ Jason.Uo.Encode.float(float)
|
194
193
|
end
|
195
194
|
end
|
196
195
|
|
197
|
- defimpl Jason.Encoder, for: List do
|
196
|
+ defimpl Jason.Uo.Encoder, for: List do
|
198
197
|
def encode(list, opts) do
|
199
|
- Jason.Encode.list(list, opts)
|
198
|
+ Jason.Uo.Encode.list(list, opts)
|
200
199
|
end
|
201
200
|
end
|
202
201
|
|
203
|
- defimpl Jason.Encoder, for: Map do
|
202
|
+ defimpl Jason.Uo.Encoder, for: Map do
|
204
203
|
def encode(map, opts) do
|
205
|
- Jason.Encode.map(map, opts)
|
204
|
+ Jason.Uo.Encode.map(map, opts)
|
206
205
|
end
|
207
206
|
end
|
208
207
|
|
209
|
- defimpl Jason.Encoder, for: BitString do
|
208
|
+ defimpl Jason.Uo.Encoder, for: BitString do
|
210
209
|
def encode(binary, opts) when is_binary(binary) do
|
211
|
- Jason.Encode.string(binary, opts)
|
210
|
+ Jason.Uo.Encode.string(binary, opts)
|
212
211
|
end
|
213
212
|
|
214
213
|
def encode(bitstring, _opts) do
|
|
@@ -219,21 +218,21 @@ defimpl Jason.Encoder, for: BitString do
|
219
218
|
end
|
220
219
|
end
|
221
220
|
|
222
|
- defimpl Jason.Encoder, for: [Date, Time, NaiveDateTime, DateTime] do
|
221
|
+ defimpl Jason.Uo.Encoder, for: [Date, Time, NaiveDateTime, DateTime] do
|
223
222
|
def encode(value, _opts) do
|
224
223
|
[?", @for.to_iso8601(value), ?"]
|
225
224
|
end
|
226
225
|
end
|
227
226
|
|
228
227
|
if Code.ensure_loaded?(Decimal) do
|
229
|
- defimpl Jason.Encoder, for: Decimal do
|
228
|
+ defimpl Jason.Uo.Encoder, for: Decimal do
|
230
229
|
def encode(value, _opts) do
|
231
230
|
[?", Decimal.to_string(value), ?"]
|
232
231
|
end
|
233
232
|
end
|
234
233
|
end
|
235
234
|
|
236
|
- defimpl Jason.Encoder, for: Jason.Fragment do
|
235
|
+ defimpl Jason.Uo.Encoder, for: Jason.Uo.Fragment do
|
237
236
|
def encode(%{encode: encode}, opts) do
|
238
237
|
encode.(opts)
|
239
238
|
end
|
changed
lib/formatter.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defmodule Jason.Formatter do
|
1
|
+ defmodule Jason.Uo.Formatter do
|
2
2
|
@moduledoc ~S"""
|
3
3
|
Pretty-printing and minimizing functions for JSON-encoded data.
|
4
4
|
|
|
@@ -36,7 +36,7 @@ defmodule Jason.Formatter do
|
36
36
|
|
37
37
|
## Examples
|
38
38
|
|
39
|
- iex> Jason.Formatter.pretty_print(~s|{"a":{"b": [1, 2]}}|)
|
39
|
+ iex> Jason.Uo.Formatter.pretty_print(~s|{"a":{"b": [1, 2]}}|)
|
40
40
|
~s|{
|
41
41
|
"a": {
|
42
42
|
"b": [
|
|
@@ -88,7 +88,7 @@ defmodule Jason.Formatter do
|
88
88
|
|
89
89
|
## Examples
|
90
90
|
|
91
|
- iex> Jason.Formatter.minimize(~s|{ "a" : "b" , "c": \n\n 2}|)
|
91
|
+ iex> Jason.Uo.Formatter.minimize(~s|{ "a" : "b" , "c": \n\n 2}|)
|
92
92
|
~s|{"a":"b","c":2}|
|
93
93
|
|
94
94
|
"""
|
changed
lib/fragment.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defmodule Jason.Fragment do
|
1
|
+ defmodule Jason.Uo.Fragment do
|
2
2
|
@moduledoc ~S"""
|
3
3
|
Provides a way to inject an already-encoded JSON structure into a
|
4
4
|
to-be-encoded structure in optimized fashion.
|
changed
lib/helpers.ex
|
@@ -1,18 +1,18 @@
|
1
|
- defmodule Jason.Helpers do
|
1
|
+ defmodule Jason.Uo.Helpers do
|
2
2
|
@moduledoc """
|
3
3
|
Provides macro facilities for partial compile-time encoding of JSON.
|
4
4
|
"""
|
5
5
|
|
6
|
- alias Jason.{Codegen, Fragment}
|
6
|
+ alias Jason.Uo.{Codegen, Fragment}
|
7
7
|
|
8
8
|
@doc ~S"""
|
9
9
|
Encodes a JSON map from a compile-time keyword.
|
10
10
|
|
11
11
|
Encodes the keys at compile time and strives to create as flat iodata
|
12
12
|
structure as possible to achieve maximum efficiency. Does encoding
|
13
|
- right at the call site, but returns an `%Jason.Fragment{}` struct
|
13
|
+ right at the call site, but returns an `%Jason.Uo.Fragment{}` struct
|
14
14
|
that needs to be passed to one of the "main" encoding functions -
|
15
|
- for example `Jason.encode/2` for final encoding into JSON - this
|
15
|
+ for example `Jason.Uo.encode/2` for final encoding into JSON - this
|
16
16
|
makes it completely transparent for most uses.
|
17
17
|
|
18
18
|
Only allows keys that do not require escaping in any of the supported
|
|
@@ -25,7 +25,7 @@ defmodule Jason.Helpers do
|
25
25
|
## Example
|
26
26
|
|
27
27
|
iex> fragment = json_map(foo: 1, bar: 2)
|
28
|
- iex> Jason.encode!(fragment)
|
28
|
+ iex> Jason.Uo.encode!(fragment)
|
29
29
|
"{\"foo\":1,\"bar\":2}"
|
30
30
|
|
31
31
|
"""
|
|
@@ -63,7 +63,7 @@ defmodule Jason.Helpers do
|
63
63
|
|
64
64
|
iex> map = %{a: 1, b: 2, c: 3}
|
65
65
|
iex> fragment = json_map_take(map, [:c, :b])
|
66
|
- iex> Jason.encode!(fragment)
|
66
|
+ iex> Jason.Uo.encode!(fragment)
|
67
67
|
"{\"c\":3,\"b\":2}"
|
68
68
|
|
69
69
|
"""
|
changed
lib/jason.ex
|
@@ -1,9 +1,9 @@
|
1
|
- defmodule Jason do
|
1
|
+ defmodule Jason.Uo do
|
2
2
|
@moduledoc """
|
3
3
|
A blazing fast JSON parser and generator in pure Elixir.
|
4
4
|
"""
|
5
5
|
|
6
|
- alias Jason.{Encode, Decoder, DecodeError, EncodeError, Formatter}
|
6
|
+ alias Jason.Uo.{Encode, Decoder, DecodeError, EncodeError, Formatter}
|
7
7
|
|
8
8
|
@type escape :: :json | :unicode_safe | :html_safe | :javascript_safe
|
9
9
|
@type maps :: :naive | :strict
|
|
@@ -48,7 +48,7 @@ defmodule Jason do
|
48
48
|
* `:objects` - controls how objects are decoded. Possible values are:
|
49
49
|
|
50
50
|
* `:maps` (default) - objects are decoded as maps
|
51
|
- * `:ordered_objects` - objects are decoded as `Jason.OrderedObject` structs
|
51
|
+ * `:ordered_objects` - objects are decoded as `Jason.Uo.OrderedObject` structs
|
52
52
|
|
53
53
|
## Decoding keys to atoms
|
54
54
|
|
|
@@ -58,11 +58,11 @@ defmodule Jason do
|
58
58
|
|
59
59
|
## Examples
|
60
60
|
|
61
|
- iex> Jason.decode("{}")
|
61
|
+ iex> Jason.Uo.decode("{}")
|
62
62
|
{:ok, %{}}
|
63
63
|
|
64
|
- iex> Jason.decode("invalid")
|
65
|
- {:error, %Jason.DecodeError{data: "invalid", position: 0, token: nil}}
|
64
|
+ iex> Jason.Uo.decode("invalid")
|
65
|
+ {:error, %Jason.Uo.DecodeError{data: "invalid", position: 0, token: nil}}
|
66
66
|
"""
|
67
67
|
@spec decode(iodata, [decode_opt]) :: {:ok, term} | {:error, DecodeError.t()}
|
68
68
|
def decode(input, opts \\ []) do
|
|
@@ -78,11 +78,11 @@ defmodule Jason do
|
78
78
|
|
79
79
|
## Examples
|
80
80
|
|
81
|
- iex> Jason.decode!("{}")
|
81
|
+ iex> Jason.Uo.decode!("{}")
|
82
82
|
%{}
|
83
83
|
|
84
|
- iex> Jason.decode!("invalid")
|
85
|
- ** (Jason.DecodeError) unexpected byte at position 0: 0x69 ("i")
|
84
|
+ iex> Jason.Uo.decode!("invalid")
|
85
|
+ ** (Jason.Uo.DecodeError) unexpected byte at position 0: 0x69 ("i")
|
86
86
|
|
87
87
|
"""
|
88
88
|
@spec decode!(iodata, [decode_opt]) :: term | no_return
|
|
@@ -96,7 +96,7 @@ defmodule Jason do
|
96
96
|
@doc """
|
97
97
|
Generates JSON corresponding to `input`.
|
98
98
|
|
99
|
- The generation is controlled by the `Jason.Encoder` protocol,
|
99
|
+ The generation is controlled by the `Jason.Uo.Encoder` protocol,
|
100
100
|
please refer to the module to read more on how to define the protocol
|
101
101
|
for custom data types.
|
102
102
|
|
|
@@ -122,15 +122,15 @@ defmodule Jason do
|
122
122
|
* `:pretty` - controls pretty printing of the output. Possible values are:
|
123
123
|
|
124
124
|
* `true` to pretty print with default configuration
|
125
|
- * a keyword of options as specified by `Jason.Formatter.pretty_print/2`.
|
125
|
+ * a keyword of options as specified by `Jason.Uo.Formatter.pretty_print/2`.
|
126
126
|
|
127
127
|
## Examples
|
128
128
|
|
129
|
- iex> Jason.encode(%{a: 1})
|
129
|
+ iex> Jason.Uo.encode(%{a: 1})
|
130
130
|
{:ok, ~S|{"a":1}|}
|
131
131
|
|
132
|
- iex> Jason.encode("\\xFF")
|
133
|
- {:error, %Jason.EncodeError{message: "invalid byte 0xFF in <<255>>"}}
|
132
|
+ iex> Jason.Uo.encode("\\xFF")
|
133
|
+ {:error, %Jason.Uo.EncodeError{message: "invalid byte 0xFF in <<255>>"}}
|
134
134
|
|
135
135
|
"""
|
136
136
|
@spec encode(term, [encode_opt]) ::
|
|
@@ -150,11 +150,11 @@ defmodule Jason do
|
150
150
|
|
151
151
|
## Examples
|
152
152
|
|
153
|
- iex> Jason.encode!(%{a: 1})
|
153
|
+ iex> Jason.Uo.encode!(%{a: 1})
|
154
154
|
~S|{"a":1}|
|
155
155
|
|
156
|
- iex> Jason.encode!("\\xFF")
|
157
|
- ** (Jason.EncodeError) invalid byte 0xFF in <<255>>
|
156
|
+ iex> Jason.Uo.encode!("\\xFF")
|
157
|
+ ** (Jason.Uo.EncodeError) invalid byte 0xFF in <<255>>
|
158
158
|
|
159
159
|
"""
|
160
160
|
@spec encode!(term, [encode_opt]) :: String.t() | no_return
|
|
@@ -176,12 +176,12 @@ defmodule Jason do
|
176
176
|
|
177
177
|
## Examples
|
178
178
|
|
179
|
- iex> {:ok, iodata} = Jason.encode_to_iodata(%{a: 1})
|
179
|
+ iex> {:ok, iodata} = Jason.Uo.encode_to_iodata(%{a: 1})
|
180
180
|
iex> IO.iodata_to_binary(iodata)
|
181
181
|
~S|{"a":1}|
|
182
182
|
|
183
|
- iex> Jason.encode_to_iodata("\\xFF")
|
184
|
- {:error, %Jason.EncodeError{message: "invalid byte 0xFF in <<255>>"}}
|
183
|
+ iex> Jason.Uo.encode_to_iodata("\\xFF")
|
184
|
+ {:error, %Jason.Uo.EncodeError{message: "invalid byte 0xFF in <<255>>"}}
|
185
185
|
|
186
186
|
"""
|
187
187
|
@spec encode_to_iodata(term, [encode_opt]) ::
|
|
@@ -198,12 +198,12 @@ defmodule Jason do
|
198
198
|
|
199
199
|
## Examples
|
200
200
|
|
201
|
- iex> iodata = Jason.encode_to_iodata!(%{a: 1})
|
201
|
+ iex> iodata = Jason.Uo.encode_to_iodata!(%{a: 1})
|
202
202
|
iex> IO.iodata_to_binary(iodata)
|
203
203
|
~S|{"a":1}|
|
204
204
|
|
205
|
- iex> Jason.encode_to_iodata!("\\xFF")
|
206
|
- ** (Jason.EncodeError) invalid byte 0xFF in <<255>>
|
205
|
+ iex> Jason.Uo.encode_to_iodata!("\\xFF")
|
206
|
+ ** (Jason.Uo.EncodeError) invalid byte 0xFF in <<255>>
|
207
207
|
|
208
208
|
"""
|
209
209
|
@spec encode_to_iodata!(term, [encode_opt]) :: iodata | no_return
|
changed
lib/ordered_object.ex
|
@@ -1,4 +1,4 @@
|
1
|
- defmodule Jason.OrderedObject do
|
1
|
+ defmodule Jason.Uo.OrderedObject do
|
2
2
|
@doc """
|
3
3
|
Struct implementing a JSON object retaining order of properties.
|
4
4
|
|
|
@@ -74,7 +74,7 @@ defmodule Jason.OrderedObject do
|
74
74
|
defp delete_key([], _key), do: []
|
75
75
|
end
|
76
76
|
|
77
|
- defimpl Enumerable, for: Jason.OrderedObject do
|
77
|
+ defimpl Enumerable, for: Jason.Uo.OrderedObject do
|
78
78
|
def count(%{values: []}), do: {:ok, 0}
|
79
79
|
def count(_obj), do: {:error, __MODULE__}
|
80
80
|
|
|
@@ -87,8 +87,8 @@ defimpl Enumerable, for: Jason.OrderedObject do
|
87
87
|
def reduce(%{values: values}, acc, fun), do: Enumerable.List.reduce(values, acc, fun)
|
88
88
|
end
|
89
89
|
|
90
|
- defimpl Jason.Encoder, for: Jason.OrderedObject do
|
90
|
+ defimpl Jason.Uo.Encoder, for: Jason.Uo.OrderedObject do
|
91
91
|
def encode(%{values: values}, opts) do
|
92
|
- Jason.Encode.keyword(values, opts)
|
92
|
+ Jason.Uo.Encode.keyword(values, opts)
|
93
93
|
end
|
94
94
|
end
|
changed
lib/sigil.ex
|
@@ -1,15 +1,15 @@
|
1
|
- defmodule Jason.Sigil do
|
1
|
+ defmodule Jason.Uo.Sigil do
|
2
2
|
@doc ~S"""
|
3
3
|
Handles the sigil `~j` for JSON strings.
|
4
4
|
|
5
|
- Calls `Jason.decode!/2` with modifiers mapped to options.
|
5
|
+ Calls `Jason.Uo.decode!/2` with modifiers mapped to options.
|
6
6
|
|
7
7
|
Given a string literal without interpolations, decodes the
|
8
8
|
string at compile-time.
|
9
9
|
|
10
10
|
## Modifiers
|
11
11
|
|
12
|
- See `Jason.decode/2` for detailed descriptions.
|
12
|
+ See `Jason.Uo.decode/2` for detailed descriptions.
|
13
13
|
|
14
14
|
* `a` - equivalent to `{:keys, :atoms}` option
|
15
15
|
* `A` - equivalent to `{:keys, :atoms!}` option
|
|
@@ -40,11 +40,11 @@ defmodule Jason.Sigil do
|
40
40
|
defmacro sigil_j(term, modifiers)
|
41
41
|
|
42
42
|
defmacro sigil_j({:<<>>, _meta, [string]}, modifiers) when is_binary(string) do
|
43
|
- Macro.escape(Jason.decode!(string, mods_to_opts(modifiers)))
|
43
|
+ Macro.escape(Jason.Uo.decode!(string, mods_to_opts(modifiers)))
|
44
44
|
end
|
45
45
|
|
46
46
|
defmacro sigil_j(term, modifiers) do
|
47
|
- quote(do: Jason.decode!(unquote(term), unquote(mods_to_opts(modifiers))))
|
47
|
+ quote(do: Jason.Uo.decode!(unquote(term), unquote(mods_to_opts(modifiers))))
|
48
48
|
end
|
49
49
|
|
50
50
|
@doc ~S"""
|
|
@@ -67,10 +67,10 @@ defmodule Jason.Sigil do
|
67
67
|
defmacro sigil_J(term, modifiers)
|
68
68
|
|
69
69
|
defmacro sigil_J({:<<>>, _meta, [string]}, modifiers) when is_binary(string) do
|
70
|
- Macro.escape(Jason.decode!(string, mods_to_opts(modifiers)))
|
70
|
+ Macro.escape(Jason.Uo.decode!(string, mods_to_opts(modifiers)))
|
71
71
|
end
|
72
72
|
|
73
|
- @spec mods_to_opts(charlist) :: [Jason.decode_opt()]
|
73
|
+ @spec mods_to_opts(charlist) :: [Jason.Uo.decode_opt()]
|
74
74
|
defp mods_to_opts(modifiers) do
|
75
75
|
modifiers
|
76
76
|
|> Enum.map(fn
|
changed
mix.exs
|
@@ -1,8 +1,8 @@
|
1
|
- defmodule Jason.Mixfile do
|
1
|
+ defmodule Jason.Uo.Mixfile do
|
2
2
|
use Mix.Project
|
3
3
|
|
4
4
|
@source_url "https://github.com/noizu-labs-scaffolding/jason"
|
5
|
- @version "1.4.98"
|
5
|
+ @version "1.4.99"
|
6
6
|
|
7
7
|
def project() do
|
8
8
|
[
|
|
@@ -31,7 +31,8 @@ defmodule Jason.Mixfile do
|
31
31
|
{:decimal, "~> 1.0 or ~> 2.0", optional: true},
|
32
32
|
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
|
33
33
|
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
|
34
|
- {:jason_native, ">= 0.0.0", optional: true}
|
34
|
+ {:jason_native, ">= 0.0.0", optional: true},
|
35
|
+ {:jason, "~> 1.4", optional: true},
|
35
36
|
] ++ maybe_stream_data()
|
36
37
|
end
|
37
38
|
|
|
@@ -68,7 +69,7 @@ defmodule Jason.Mixfile do
|
68
69
|
main: "readme",
|
69
70
|
name: "Jason",
|
70
71
|
source_ref: "v#{@version}",
|
71
|
- canonical: "http://hexdocs.pm/jason",
|
72
|
+ canonical: "http://hexdocs.pm/jason_uo",
|
72
73
|
source_url: @source_url,
|
73
74
|
extras: ["README.md", "CHANGELOG.md", "LICENSE"]
|
74
75
|
]
|