Fix emqx_json encode return types error

This commit is contained in:
JianBo He 2020-03-21 13:38:48 +08:00
parent 4ba3c343f0
commit 5e02c569f2
1 changed files with 5 additions and 1 deletions

View File

@ -55,7 +55,7 @@ encode(Term) ->
-spec(encode(json_term(), encode_options()) -> json_text()).
encode(Term, Opts) ->
jiffy:encode(to_ejson(Term), Opts).
to_binary(jiffy:encode(to_ejson(Term), Opts)).
-spec(safe_encode(json_term())
-> {ok, json_text()} | {error, Reason :: term()}).
@ -118,3 +118,7 @@ from_ejson({L}) ->
[{Name, from_ejson(Value)} || {Name, Value} <- L];
from_ejson(T) -> T.
to_binary(B) when is_binary(B) -> B;
to_binary(L) when is_list(L) ->
iolist_to_binary(L).