Skip to content

Commit 9b21914

Browse files
authored
Merge pull request #18 from nalundgaard/v2.0.0
Introduce version 2.0.0
2 parents d2cffda + 8eb5df8 commit 9b21914

File tree

9 files changed

+106
-640
lines changed

9 files changed

+106
-640
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ otp_release:
44
- 20.1
55
- 19.3
66
- 18.3
7-
- 17.5
8-
- R16B03-1
97
install: true
108
script:
119
- ./rebar3 compile

README.md

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ JSON objects in particular.
77

88
In the spirit of [ej][ej], it supports the common formats output by JSON
99
decoders such as [jsone][jsone], [jiffy][jiffy], and [mochijson2][mochijson2].
10-
Unlike [ej][ej], however, it supports _all three_ common JSON representations
10+
Unlike [ej][ej], however, it supports _all four_ common JSON representations
1111
in Erlang:
1212

13-
* `proplist` (**default**)(used by [jsonx][jsonx])
14-
* `map` (common to [jsone][jsone], [jiffy][jiffy], and [jsx][jsx])
13+
* `map` (**default**)(common to [jsone][jsone], [jiffy][jiffy], and [jsx][jsx])
14+
* `proplist` (used by [jsonx][jsonx])
1515
* `eep18` (common to [jiffy][jiffy], [jsone][jsone], and [jsonx][jsonx])
1616
* `struct` (common to [mochijson2][mochijson2])
1717

@@ -28,27 +28,6 @@ it has been refactored to be a nearly standalone library.
2828

2929
## Caveats & known issues
3030

31-
### Deprecated: Erlang 17 or lower
32-
33-
jsn will no longer support Erlang 17 or previous Erlang releases. Allowing the
34-
`map` format to work without breaking Erlang versions that do not support maps
35-
(or have an incomplete implementation of maps, i.e., Erlang 17) requires
36-
inelegant conditional macros throughout the code and test. This support will
37-
be removed in the next major version of jsn.
38-
39-
### Deprecated: encoding and decoding
40-
41-
jsn will no longer support encoding and decoding. It will be removed in the next
42-
major version of jsn. See [below](#encode-decode) for more information.
43-
44-
### Deprecated: key sorting functions
45-
46-
jsn will no longer support the `jsn:sort/1`, `jsn:sort_keys/1`, and
47-
`jsn:sort_equal/2` functions. These functions are incompatible with the `map`
48-
format; the ambiguity of library functions which are only partially compatible
49-
with the supported formats is confusing for clients. For this reason, the
50-
functions will be removed in the next major version of jsn.
51-
5231
### Proplist format concerns
5332

5433
It should be noted that the `proplist` format supported by jsn is compatible with
@@ -69,25 +48,9 @@ jsn does not plan to support a [jsx][jsx] and [jsone][jsone] compatible
6948
format instead. It a vastly more performant data structure that maps naturally
7049
to JSON objects without ambiguity.
7150

72-
### Edoc generation broken by map support
73-
74-
the `edoc` make target (and using `rebar3 edoc`) are currently broken due to a
75-
parser problem triggered by the `IF_MAPS(...)` macro used to implement the
76-
`map` format in a backwards-compatible fashion. Edoc support will be restored
77-
when this problem is addressed in Erlang or the `map` backwards-compatibility
78-
constructions are removed from jsn in a future version.
79-
8051
## Roadmap
8152

82-
### 2.0.0
83-
84-
* **Remove deprecated functions `jsn:sort/1`, `jsn:sort_keys/1`, and `jsn:sort_equal/2`**.
85-
* **Remove deprecated support for Erlang 17 and lower**. Full `map` support will be
86-
assumed by the code, and these older versions will no longer be able to
87-
compile jsn.
88-
* **Make `map` the default object format**. Maps are superior to proplists for
89-
JSON object representation in Erlang, and will be favored primarily by the
90-
library.
53+
Future improvements to this library are TBD at this time.
9154

9255
## Running
9356

@@ -160,8 +123,8 @@ There are 3 different supported path styles, each with different tradeoffs:
160123
## Library functions
161124

162125
jsn provides functions to create, append, delete, and transform objects in all
163-
supported formats (`proplist`, `eep18`, and `struct`). This section contains a
164-
reference for the primary library functions available.
126+
supported formats (`map`, `proplist`, `eep18`, and `struct`). This section
127+
contains a reference for the primary library functions available.
165128

166129
### `new/0,1,2` - Create a new object
167130

@@ -514,18 +477,6 @@ jsn:transform([{key1, T1},{key2, T1},{key4, T1}], NewDestination).
514477
% {<<"key2">>,<<"2">>}]
515478
```
516479

517-
### <a name="encode-decode"></a>`encode/1` and `decode/1,2` - Encoding/decoding JSON for interaction with jsn
518-
519-
**NOTE**: encoding and decoding are **deprecated**, and will be removed in a
520-
future version of jsn (`2.x.x`). the [jsonx][jsonx] library that jsn uses for
521-
this functionality is abandoned, and users are strongly advised to use any of
522-
the many Erlang JSON libraries available:
523-
524-
* [jiffy][jiffy] (`eep18` and `map` formats)
525-
* [jsone][jsone] (`eep18`, `proplist`, and `map` formats)
526-
* [jsx][jsx] (`proplist` and `map` formats)
527-
* [mochijson2][mochijson2] (`struct` format)
528-
529480
### `equal/3,4` - Path-wise object comparison
530481

531482
* `equal(Paths, OriginalObject, OtherObjectOrObjects)` - Given a list of paths,

erl.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

include/jsn.hrl

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@
1616
-type json_boolean() :: true | false.
1717
-type json_null() :: null.
1818
-type json_array() :: [json_term()].
19-
-type json_no_map_array() :: [json_no_map_term()].
2019
-type json_array_index() :: first | last | pos_integer().
20+
-type json_map() :: #{json_key() => json_term()}.
2121
-type json_proplist() :: [{json_key(), json_term()}].
2222
-type json_eep18() :: {json_proplist()}.
2323
-type json_struct() :: {struct, json_proplist()}.
24-
-type json_no_map_object() :: json_proplist() | json_eep18() | json_struct().
25-
-ifdef(maps_support).
26-
-type json_map() :: #{json_key() => json_term()}.
27-
-type json_object() :: json_no_map_object() | json_map().
28-
-else.
29-
-type json_object() :: json_no_map_object().
30-
-endif.
31-
-type json_no_map_term() :: json_string() | json_number() | json_no_map_array() |
32-
json_null() | json_boolean() | json_no_map_object().
24+
-type json_object() :: json_map() |json_proplist() | json_eep18() | json_struct().
3325
-type json_term() :: json_string() | json_number() | json_array() |
3426
json_null() | json_boolean() | json_object().
3527

@@ -43,11 +35,7 @@
4335
%% * eep18 (a.k.a EJSON)
4436
%% * struct (mochijson2 format)
4537
%%
46-
-ifdef(maps_support).
4738
-type format() :: map | proplist | eep18 | struct.
48-
-else.
49-
-type format() :: proplist | eep18 | struct.
50-
-endif.
5139
-type jsn_option() :: {format, format()}.
5240
-type jsn_options() :: [ jsn_option() ].
5341

@@ -91,11 +79,6 @@
9179

9280
-define(EMPTY_STRUCT, {struct, []}).
9381

94-
-ifdef(maps_support).
95-
-define(IF_MAPS(Expr), Expr).
9682
-define(EMPTY_MAP, #{}).
97-
-else.
98-
-define(IF_MAPS(_), ).
99-
-endif.
10083

10184
-endif.

rebar.config

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
{deps, [{jsonx, {git, "https://github.com/alertlogic/jsonx.git", {branch, master}}}]}.
2-
3-
{erl_opts, [{platform_define, "^1[89]|^[2-9][0-9]+", maps_support},
4-
{platform_define, "^1[89]|^[2-9][0-9]+", has_rand},
5-
inline_list_funcs,
1+
{erl_opts, [inline_list_funcs,
62
warn_deprecated_function,
73
warn_export_vars,
84
warn_obsolete_guard,

rebar.lock

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
[{<<"jsonx">>,
2-
{git,"https://github.com/alertlogic/jsonx.git",
3-
{ref,"02ddffb5da9c6d1664bda89b459480b69ebff258"}},
4-
0}].
1+
[].

src/jsn.app.src

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{application, jsn, [
22
{description, "Utilities for interacting with decoded JSON in erlang"},
3-
{vsn, "1.2.1"}, %% <- need to set this appropriately when publishing to hex.pm
3+
{vsn, "2.0.0"},
44
{applications, [kernel,
5-
stdlib,
6-
jsonx]},
5+
stdlib
6+
]},
77
{maintainers, ["Nicholas Lundgaard", "Mark Allen"]},
88
{licenses, ["Apache 2"]},
99
{links, [{"Github", "https://github.com/nalundgaard/jsn"}]}

0 commit comments

Comments
 (0)