Skip to content

Commit b59e144

Browse files
committed
Merge pull request #40 from bb4242/master
Allow packing maps even when {format,map} is not set.
2 parents 69d5aa8 + 39a0ead commit b59e144

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/msgpack_packer.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ handle_binary(Bin, Opt) ->
122122
end.
123123

124124
%% %% map interface
125-
handle_ext(Map, Opt = ?OPTION{interface=map}) when is_map(Map) ->
125+
handle_ext(Map, Opt) when is_map(Map) ->
126126
pack_map(maps:to_list(Map), Opt);
127127

128128
handle_ext(Any, _Opt = ?OPTION{ext_packer=Packer,

test/msgpack_test.erl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ map_test_()->
237237
?assertEqual(BinaryJSX, Binary)
238238
end},
239239

240+
{"pack map without {format,map}",
241+
fun() ->
242+
Map = maps:from_list([ {X, X * 2} || X <- lists:seq(0, 16) ]),
243+
Binary = pack(Map),
244+
?assertEqual({ok,Map}, unpack(Binary, [{format,map}]))
245+
end},
246+
240247
{"map length 16",
241248
fun() ->
242249
Map = maps:from_list([ {X, X * 2} || X <- lists:seq(0, 16) ]),

0 commit comments

Comments
 (0)