Skip to content

Commit 696226d

Browse files
committed
Merge branch 'master' into map
2 parents 09aff9e + b8040f6 commit 696226d

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/msgpack.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{application, msgpack,
22
[{description, "MessagePack serializer/deserializer"},
3-
{vsn, "0.2.7"},
3+
{vsn, "0.2.8"},
44
{modules,
55
[msgpack]
66
},

src/msgpack_packer.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pack(I, _) when is_integer(I) ->
3232
pack_uint(I);
3333
pack(F, _) when is_float(F) ->
3434
pack_double(F);
35-
pack(nil, _) ->
35+
pack(null, _Opt = ?OPTION{interface=jsx}) ->
36+
<< 16#C0:8 >>;
37+
pack(nil, _Opt = ?OPTION{interface=Interface})
38+
when Interface =/= jsx ->
3639
<< 16#C0:8 >>;
3740
pack(false, _) ->
3841
<< 16#C2:8 >>;

src/msgpack_unpacker.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
%% unpack them all
3434
-spec unpack_stream(Bin::binary(), msgpack_option()) -> {msgpack:object(), binary()} | no_return().
3535
%% ATOMS
36+
unpack_stream(<<16#C0, Rest/binary>>, _Opt = ?OPTION{interface=jsx}) ->
37+
{null, Rest};
3638
unpack_stream(<<16#C0, Rest/binary>>, _) ->
3739
{nil, Rest};
3840
unpack_stream(<<16#C2, Rest/binary>>, _) ->

test/msgpack_test.erl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ issue_jiffy_5_test() ->
144144
?assertEqual(Term, Decoded).
145145

146146

147+
issue_27_test_() ->
148+
[?_assertEqual({ok, null},
149+
msgpack:unpack(msgpack:pack(nil), [{format,jsx}])),
150+
?_assertEqual({ok, nil},
151+
msgpack:unpack(msgpack:pack(null, [{format,jsx}]))),
152+
?_assertEqual({ok, <<"null">>},
153+
msgpack:unpack(msgpack:pack(null, [{allow_atom,pack}]))),
154+
?_assertEqual({ok, <<"nil">>},
155+
msgpack:unpack(msgpack:pack(nil,
156+
[{format,jsx},{allow_atom,pack}])))].
157+
147158
string_test() ->
148159
{ok, CWD} = file:get_cwd(),
149160
Path = CWD ++ "/../test/utf8.txt",

0 commit comments

Comments
 (0)