Fix emqx_json encode return types error
This commit is contained in:
parent
4ba3c343f0
commit
5e02c569f2
|
@ -55,7 +55,7 @@ encode(Term) ->
|
||||||
|
|
||||||
-spec(encode(json_term(), encode_options()) -> json_text()).
|
-spec(encode(json_term(), encode_options()) -> json_text()).
|
||||||
encode(Term, Opts) ->
|
encode(Term, Opts) ->
|
||||||
jiffy:encode(to_ejson(Term), Opts).
|
to_binary(jiffy:encode(to_ejson(Term), Opts)).
|
||||||
|
|
||||||
-spec(safe_encode(json_term())
|
-spec(safe_encode(json_term())
|
||||||
-> {ok, json_text()} | {error, Reason :: term()}).
|
-> {ok, json_text()} | {error, Reason :: term()}).
|
||||||
|
@ -118,3 +118,7 @@ from_ejson({L}) ->
|
||||||
[{Name, from_ejson(Value)} || {Name, Value} <- L];
|
[{Name, from_ejson(Value)} || {Name, Value} <- L];
|
||||||
from_ejson(T) -> T.
|
from_ejson(T) -> T.
|
||||||
|
|
||||||
|
to_binary(B) when is_binary(B) -> B;
|
||||||
|
to_binary(L) when is_list(L) ->
|
||||||
|
iolist_to_binary(L).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue