From 50eff667a1408afccda848d22b851e292450cd95 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Thu, 8 Oct 2015 22:58:19 -0700 Subject: [PATCH 1/7] v2.8.0 --- README.md | 10 ++++------ mix.exs | 2 +- src/jsx.app.src | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 48baf11..a20b7c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# jsx (v2.7.2) # +# jsx (v2.8.0) # an erlang application for consuming, producing and manipulating [json][json]. @@ -120,7 +120,7 @@ false }">> ``` -#### to compile **jsx** so that it always decodes json objects to maps #### +#### to compile **jsx** so that it always decodes json objects to maps #### ```bash $ JSX_FORCE_MAPS rebar3 compile @@ -166,11 +166,9 @@ ignores bad escape sequences leaving them in strings unaltered if you're migrating from jsx v1.x to v2.x in most cases you won't need to make any changes to your code -support for encoding otp 17.0's new map type is now enabled by default when compiling +support for otp 17.0's new map type is now enabled by default when compiling via rebar for any release that supports them. jsx should still compile cleanly for -earlier releases without any user intervention. if you'd like to disable maps you can -either set the env variable `JSX_NOMAPS` or by uncommenting the applicable tuple in -`rebar.config` +earlier releases without any user intervention if you used any of `replaced_bad_utf8`, `single_quoted_strings`, `comments`, `ignored_bad_escapes` or `relax` you can simply omit them from your calls to jsx, diff --git a/mix.exs b/mix.exs index b6e996a..17272aa 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ use Mix.Project def project do [ app: :jsx, - version: "2.7.2", + version: "2.8.0", description: "an erlang application for consuming, producing and manipulating json. inspired by yajl", deps: deps(Mix.env), package: package, diff --git a/src/jsx.app.src b/src/jsx.app.src index 73415db..f7c384e 100644 --- a/src/jsx.app.src +++ b/src/jsx.app.src @@ -1,7 +1,7 @@ {application, jsx, [ {description, "a streaming, evented json parsing toolkit"}, - {vsn, "2.7.2"}, + {vsn, "2.8.0"}, {modules, [ jsx, jsx_encoder, From 5e0df7b77d517e1e5dec27c593b5693243db8ae6 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Mon, 12 Oct 2015 14:56:11 +0100 Subject: [PATCH 2/7] Match jsx:json_term() / jsx_to_term:json_value() specs for empty object. --- src/jsx.erl | 4 ++-- src/jsx_to_term.erl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jsx.erl b/src/jsx.erl index 0b55b2e..acdf420 100644 --- a/src/jsx.erl +++ b/src/jsx.erl @@ -44,7 +44,7 @@ -ifndef(maps_support). --type json_term() :: [{binary() | atom(), json_term()}] | [{}] +-type json_term() :: [{binary() | atom(), json_term()}] | [{},...] | [json_term()] | [] | true | false | null | integer() | float() @@ -53,7 +53,7 @@ -endif. -ifdef(maps_support). --type json_term() :: [{binary() | atom(), json_term()}] | [{}] +-type json_term() :: [{binary() | atom(), json_term()}] | [{},...] | [json_term()] | [] | map() | true | false | null diff --git a/src/jsx_to_term.erl b/src/jsx_to_term.erl index ec9ab89..aa05264 100644 --- a/src/jsx_to_term.erl +++ b/src/jsx_to_term.erl @@ -46,7 +46,7 @@ -ifndef(maps_support). -type json_value() :: list(json_value()) - | list({binary() | atom(), json_value()}) + | list({binary() | atom(), json_value()}) | [{},...] | true | false | null @@ -57,7 +57,7 @@ -ifdef(maps_support). -type json_value() :: list(json_value()) - | list({binary() | atom(), json_value()}) + | list({binary() | atom(), json_value()}) | [{},...] | map() | true | false From 5342ed1368bdc7e8895986c2f1cda02e7ff945a2 Mon Sep 17 00:00:00 2001 From: Leonardo Rossi Date: Thu, 14 Jan 2016 22:11:17 +0100 Subject: [PATCH 3/7] global: accept erlang:timestamp() * Adds support for erlang:timestamp(). (closes #92) Signed-off-by: Leonardo Rossi --- src/jsx_parser.erl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/jsx_parser.erl b/src/jsx_parser.erl index 5dc8653..ca341c0 100644 --- a/src/jsx_parser.erl +++ b/src/jsx_parser.erl @@ -109,6 +109,17 @@ value([Number|Tokens], Handler, Stack, Config) when is_float(Number) -> maybe_done(Tokens, handle_event({float, Number}, Handler, Config), Stack, Config); value([{raw, Raw}|Tokens], Handler, Stack, Config) when is_binary(Raw) -> value((jsx:decoder(?MODULE, [], []))(Raw) ++ Tokens, Handler, Stack, Config); +value([{_,_,_}=Timestamp|Tokens], Handler, Stack, Config) -> + {{Year, Month, Day}, {Hour, Min, Sec}} = calendar:now_to_datetime( + Timestamp), + value([{string, unicode:characters_to_binary(io_lib:format( + "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ", + [Year, Month, Day, Hour, Min, Sec] + ))}|Tokens], + Handler, + Stack, + Config + ); value([{{Year, Month, Day}, {Hour, Min, Sec}}|Tokens], Handler, Stack, Config) when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_integer(Min), is_integer(Sec) -> value([{string, unicode:characters_to_binary(io_lib:format( @@ -1178,6 +1189,15 @@ datetime_test_() -> ]. +timestamp_test_() -> + [ + {"timestamp", ?_assertEqual( + [start_array, {string, <<"2016-01-15T18:19:28Z">>}, end_array, end_json], + parse([start_array, {1452,881968,111772}, end_array, end_json], []) + )} + ]. + + rogue_tuple_test_() -> [ {"kv in value position of object", ?_assertError( From 5c4a1c71d332335ab59642e0d7809027792742b2 Mon Sep 17 00:00:00 2001 From: Tyler Weir Date: Wed, 15 Jun 2016 15:49:15 -0400 Subject: [PATCH 4/7] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a20b7c2..0433858 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,16 @@ for the overview or [migrating from 1.x](#migrating) for the details ## quickstart ## +#### to add to a rebar3 project #### +Add to `rebar.config` +```erlang +{erl_opts, [debug_info]}. +{deps, [ + elli, + {jsx, {git, "https://github.com/talentdeficit/jsx.git", {branch, "v2.8.0"}}} +]}. +``` + #### to build the library and run tests #### ```bash From 5f81cf553882d02e8c95b4bcd8cb303ad95f5ffc Mon Sep 17 00:00:00 2001 From: Tyler Weir Date: Wed, 15 Jun 2016 15:49:46 -0400 Subject: [PATCH 5/7] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0433858..64c39c3 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,13 @@ for the overview or [migrating from 1.x](#migrating) for the details #### to add to a rebar3 project #### Add to `rebar.config` ```erlang +... {erl_opts, [debug_info]}. {deps, [ - elli, + ... {jsx, {git, "https://github.com/talentdeficit/jsx.git", {branch, "v2.8.0"}}} ]}. +... ``` #### to build the library and run tests #### From 7258ab9851a0447adc4d95c1e806763f551be152 Mon Sep 17 00:00:00 2001 From: Sergey Ivlev Date: Thu, 28 Jul 2016 11:48:35 +0300 Subject: [PATCH 6/7] fix mix.exs warning elixir 1.4.0 warning: variable "package" does not exist and is being expanded to "package()", please use parentheses to remove the ambiguity or change the variable name /home/ ... /deps/jsx/mix.exs:10 --- mix.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.exs b/mix.exs index 17272aa..dfc2aef 100644 --- a/mix.exs +++ b/mix.exs @@ -7,7 +7,7 @@ use Mix.Project version: "2.8.0", description: "an erlang application for consuming, producing and manipulating json. inspired by yajl", deps: deps(Mix.env), - package: package, + package: package(), language: :erlang, erlc_options: opts(Mix.env) ] From d6ddbfcaec2c07dd4cc33911af14e5810b80b36c Mon Sep 17 00:00:00 2001 From: Mike Buhot Date: Thu, 8 Sep 2016 13:34:52 +1000 Subject: [PATCH 7/7] Enable debug_info in erl_opts --- mix.exs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index dfc2aef..4fbe563 100644 --- a/mix.exs +++ b/mix.exs @@ -19,8 +19,8 @@ use Mix.Project nil -> [] _ -> [d: :maps_always] end - [d: :maps_support] ++ force_maps - end + [:debug_info, d: :maps_support] ++ force_maps + end defp deps(_), do: [{:mixunit, "~> 0.9.2", only: :dev}] @@ -41,4 +41,3 @@ use Mix.Project ] end end -