Skip to content

Commit c8e8d05

Browse files
committed
Revert the experimental 1.5 branch and jason_native experiment
1 parent 0e7a3e2 commit c8e8d05

8 files changed

Lines changed: 46 additions & 87 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Changelog
22

3-
## 1.5.0-alpha.2 (07.07.2023)
3+
## 1.4.4 (26.07.2024)
44

5-
* Add limit to decoded integer sizes of 1024 digits. This can be changed
6-
with the `decoding_integer_digit_limit` app env config.
5+
* Fix warnings on Elixir 1.17 by conditionally compiling Decimal support
76

8-
## 1.4.1 (06.07.2023)
7+
## 1.4.3 (29.06.2024)
98

10-
* Add limit to decoded integer sizes of 1024 digits. This can be changed
11-
with the `decoding_integer_digit_limit` app env config.
9+
* Fix derive with _ struct key
1210

13-
## 1.5.0-alpha.1 (16.10.2022)
11+
## 1.4.2 (29.06.2024)
1412

15-
### Enhancements
13+
* Fix compiler warnings for Elixir 1.17
14+
15+
## 1.4.1 (06.07.2023)
1616

17-
* Add optional dependency for [`jason_native`](https://github.com/spawnfest/json_native).
18-
Please refer to the repo for usage instructions
17+
* Add limit to decoded integer sizes of 1024 digits. This can be changed
18+
with the `decoding_integer_digit_limit` app env config.
1919

2020
## 1.4.0 (12.09.2022)
2121

bench/encode.exs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
encode_jobs = %{
2-
"Jason" => &Jason.encode_to_iodata!(&1, escape: :elixir_json),
3-
"Jason native" => &Jason.encode_to_iodata!(&1, escape: :native_json),
4-
# "Jason strict" => &Jason.encode_to_iodata!(&1, maps: :strict, escape: :elixir_json),
5-
"Poison" => &Poison.encode!/1,
6-
# "JSX" => &JSX.encode!/1,
7-
# "Tiny" => &Tiny.encode!/1,
8-
# "jsone" => &:jsone.encode/1,
2+
"Jason" => &Jason.encode_to_iodata!/1,
3+
"Jason strict" => &Jason.encode_to_iodata!(&1, maps: :strict),
4+
"Poison" => &Poison.encode_to_iodata!/1,
5+
"JSX" => &JSX.encode!/1,
6+
"Tiny" => &Tiny.encode!/1,
7+
"jsone" => &:jsone.encode/1,
98
"jiffy" => &:jiffy.encode/1,
10-
# "JSON" => &JSON.encode!/1,
9+
"JSON" => &JSON.encode!/1,
1110
# "term_to_binary" => &:erlang.term_to_binary/1,
1211
}
1312

@@ -36,10 +35,9 @@ end
3635

3736
Benchee.run(encode_jobs,
3837
# parallel: 4,
39-
warmup: 2,
40-
time: 15,
41-
memory_time: 0.01,
42-
reduction_time: 0.01,
38+
warmup: 5,
39+
time: 30,
40+
memory_time: 1,
4341
inputs: for name <- encode_inputs, into: %{} do
4442
name
4543
|> read_data.()

bench/mix.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ defmodule JasonBench.MixProject do
2323
defp deps do
2424
[
2525
{:jason, "~> 1.0", path: "../", override: true},
26-
{:jason_native, ">= 0.0.0"},
2726
{:benchee, "~> 1.0"},
2827
{:benchee_html, "~> 1.0"},
2928
{:poison, "~> 5.0"},

bench/mix.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"benchee_html": {:hex, :benchee_html, "1.0.0", "5b4d24effebd060f466fb460ec06576e7b34a00fc26b234fe4f12c4f05c95947", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:benchee_json, "~> 1.0", [hex: :benchee_json, repo: "hexpm", optional: false]}], "hexpm", "5280af9aac432ff5ca4216d03e8a93f32209510e925b60e7f27c33796f69e699"},
44
"benchee_json": {:hex, :benchee_json, "1.0.0", "cc661f4454d5995c08fe10dd1f2f72f229c8f0fb1c96f6b327a8c8fc96a91fe5", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "da05d813f9123505f870344d68fb7c86a4f0f9074df7d7b7e2bb011a63ec231c"},
55
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
6-
"elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"},
76
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"},
8-
"jason_native": {:hex, :jason_native, "0.1.0", "03003746213ba6da181ad9e488461969aaa6b212a48e9a57ce74ada4c71cbc1f", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "6dd4c067da7d9296425604968536f91927dbb3fa538131cdef19ad2a3a0d1ee1"},
7+
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
98
"jiffy": {:hex, :jiffy, "1.1.1", "aca10f47aa91697bf24ab9582c74e00e8e95474c7ef9f76d4f1a338d0f5de21b", [:rebar3], [], "hexpm", "62e1f0581c3c19c33a725c781dfa88410d8bff1bbafc3885a2552286b4785c4c"},
109
"json": {:hex, :json, "1.4.1", "8648f04a9439765ad449bc56a3ff7d8b11dd44ff08ffcdefc4329f7c93843dfa", [:mix], [], "hexpm", "9abf218dbe4ea4fcb875e087d5f904ef263d012ee5ed21d46e9dbca63f053d16"},
1110
"jsone": {:hex, :jsone, "1.7.0", "1e3bd7d5dd44bb2eb0797dddea1cbf2ddab8d9f29e499a467ca171c23f5984ea", [:rebar3], [], "hexpm", "a3a33712ee6bc8be10cfa21c7c425a299de4c5a8533f9f931e577a6d0e8f5dbd"},

lib/encode.ex

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ defmodule Jason.Encode do
3838
catch
3939
:throw, %EncodeError{} = e ->
4040
{:error, e}
41-
:error, {:invalid_byte, _, _} = e ->
42-
{:error, EncodeError.new(e)}
4341
:error, %Protocol.UndefinedError{protocol: Jason.Encoder} = e ->
4442
{:error, e}
4543
end
@@ -52,33 +50,15 @@ defmodule Jason.Encode do
5250
end
5351
end
5452

55-
if Code.ensure_loaded?(Jason.Native) do
56-
defp escape_function(%{escape: escape}) do
57-
case escape do
58-
:json -> &Jason.Native.escape_json/1
59-
:native_json -> &Jason.Native.escape_json/1
60-
:elixir_json -> &escape_json/1
61-
:html_safe -> &escape_html/1
62-
:unicode_safe -> &escape_unicode/1
63-
:javascript_safe -> &escape_javascript/1
64-
# Keep for compatibility with Poison
65-
:javascript -> &escape_javascript/1
66-
:unicode -> &escape_unicode/1
67-
end
68-
end
69-
else
70-
defp escape_function(%{escape: escape}) do
71-
case escape do
72-
:json -> &escape_json/1
73-
:native_json -> raise ArgumentError, "jason_native not found, :native_ options not available"
74-
:elixir_json -> &escape_json/1
75-
:html_safe -> &escape_html/1
76-
:unicode_safe -> &escape_unicode/1
77-
:javascript_safe -> &escape_javascript/1
78-
# Keep for compatibility with Poison
79-
:javascript -> &escape_javascript/1
80-
:unicode -> &escape_unicode/1
81-
end
53+
defp escape_function(%{escape: escape}) do
54+
case escape do
55+
:json -> &escape_json/1
56+
:html_safe -> &escape_html/1
57+
:unicode_safe -> &escape_unicode/1
58+
:javascript_safe -> &escape_javascript/1
59+
# Keep for compatibility with Poison
60+
:javascript -> &escape_javascript/1
61+
:unicode -> &escape_unicode/1
8262
end
8363
end
8464

mix.exs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Jason.Mixfile do
22
use Mix.Project
33

44
@source_url "https://github.com/michalmuskala/jason"
5-
@version "1.5.0-alpha.2"
5+
@version "1.4.0"
66

77
def project() do
88
[
@@ -31,7 +31,6 @@ defmodule Jason.Mixfile do
3131
{:decimal, "~> 1.0 or ~> 2.0", optional: true},
3232
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
3333
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
34-
{:jason_native, ">= 0.0.0", optional: true}
3534
] ++ maybe_stream_data()
3635
end
3736

@@ -45,7 +44,7 @@ defmodule Jason.Mixfile do
4544

4645
defp dialyzer() do
4746
[
48-
plt_add_apps: [:decimal, :jason_native]
47+
plt_add_apps: [:decimal]
4948
]
5049
end
5150

mix.lock

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
%{
2-
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
3-
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
4-
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
5-
"elixir_make": {:hex, :elixir_make, "0.8.4", "4960a03ce79081dee8fe119d80ad372c4e7badb84c493cc75983f9d3bc8bde0f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "6e7f1d619b5f61dfabd0a20aa268e575572b542ac31723293a4c1a567d5ef040"},
6-
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
7-
"ex_doc": {:hex, :ex_doc, "0.34.1", "9751a0419bc15bc7580c73fde506b17b07f6402a1e5243be9e0f05a68c723368", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d441f1a86a235f59088978eff870de2e815e290e44a8bd976fe5d64470a4c9d2"},
8-
"jason_native": {:hex, :jason_native, "0.1.0", "03003746213ba6da181ad9e488461969aaa6b212a48e9a57ce74ada4c71cbc1f", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "6dd4c067da7d9296425604968536f91927dbb3fa538131cdef19ad2a3a0d1ee1"},
9-
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},
10-
"makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"},
11-
"makeup_erlang": {:hex, :makeup_erlang, "1.0.0", "6f0eff9c9c489f26b69b61440bf1b238d95badae49adac77973cbacae87e3c2e", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "ea7a9307de9d1548d2a72d299058d1fd2339e3d398560a0e46c27dab4891e4d2"},
12-
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
13-
"stream_data": {:hex, :stream_data, "1.1.1", "fd515ca95619cca83ba08b20f5e814aaf1e5ebff114659dc9731f966c9226246", [:mix], [], "hexpm", "45d0cd46bd06738463fd53f22b70042dbb58c384bb99ef4e7576e7bb7d3b8c8c"},
2+
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
3+
"dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"},
4+
"earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"},
5+
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
6+
"ex_doc": {:hex, :ex_doc, "0.28.5", "3e52a6d2130ce74d096859e477b97080c156d0926701c13870a4e1f752363279", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d2c4b07133113e9aa3e9ba27efb9088ba900e9e51caa383919676afdf09ab181"},
7+
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
8+
"makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"},
9+
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
10+
"nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"},
11+
"stream_data": {:hex, :stream_data, "1.3.0", "bde37905530aff386dea1ddd86ecbf00e6642dc074ceffc10b7d4e41dfd6aac9", [:mix], [], "hexpm", "3cc552e286e817dca43c98044c706eec9318083a1480c52ae2688b08e2936e3c"},
1412
}

test/encode_test.exs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,11 @@ defmodule Jason.EncoderTest do
214214
end
215215

216216
assert_raise EncodeError, "invalid byte 0x80 in <<128>>", fn ->
217-
assert to_json(<<0x80>>, escape: :native_json)
218-
end
219-
220-
assert_raise EncodeError, "invalid byte 0x80 in <<128>>", fn ->
221-
assert to_json(<<0x80>>, escape: :elixir_json)
217+
assert to_json(<<0x80>>)
222218
end
223219

224220
assert_raise EncodeError, fn ->
225-
assert to_json(<<?a, 208>>, escape: :native_json)
226-
end
227-
228-
assert_raise EncodeError, fn ->
229-
assert to_json(<<?a, 208>>, escape: :elixir_json)
221+
assert to_json(<<?a, 208>>)
230222
end
231223
end
232224

@@ -244,14 +236,8 @@ defmodule Jason.EncoderTest do
244236
assert to_json(object, pretty: false) == ~s|{"a":3.14159,"b":1}|
245237
end
246238

247-
defp to_json(value) do
248-
native = Jason.encode!(value, escape: :native_json)
249-
elixir = Jason.encode!(value, escape: :elixir_json)
250-
assert native == elixir
251-
native
252-
end
253-
254-
defp to_json(value, opts) do
239+
defp to_json(value, opts \\ []) do
255240
Jason.encode!(value, opts)
256241
end
242+
257243
end

0 commit comments

Comments
 (0)