diff --git a/apps/iot/src/endpoint/iot_donghuoliren_endpoint.erl b/apps/iot/src/endpoint/iot_donghuoliren_endpoint.erl index 399ee90..5f49965 100644 --- a/apps/iot/src/endpoint/iot_donghuoliren_endpoint.erl +++ b/apps/iot/src/endpoint/iot_donghuoliren_endpoint.erl @@ -106,7 +106,7 @@ handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, iot_logger:write(LoggerPid, [<<"OK">>, list_to_binary(Url1), Body, RespBody]), {noreply, State#state{succ_counter = SuccCounter + 1}}; {error, Reason} -> - NReason = iolist_to_binary(io_lib:format("~p", Reason)), + NReason = iolist_to_binary(io_lib:format("~p", [Reason])), iot_logger:write(LoggerPid, [<<"ERROR">>, list_to_binary(Url1), Body, NReason]), {noreply, State#state{fail_counter = FailCounter + 1}} end. @@ -211,7 +211,21 @@ serialize0([{K, V}|T], Target) -> is_boolean(V) andalso not V -> <<"false">>; is_list(V) -> - V0 = iolist_to_binary(lists:join(<<$,>>, V)), + Items = lists:map(fun(E) -> + if + is_integer(E) -> + integer_to_binary(E); + is_float(E) -> + float_to_binary(E); + is_binary(E) -> + <<$", E/binary, $">>; + is_boolean(E) andalso E -> + <<"true">>; + is_boolean(E) andalso not E -> + <<"false">> + end + end, V), + V0 = iolist_to_binary(lists:join(<<$,>>, Items)), <<$[, V0/binary, $]>> end, Item = <<$", K/binary, $", $:, V1/binary>>,