From 13c8a5d359415332e7294df9a7cbfc6883859b42 Mon Sep 17 00:00:00 2001 From: lsxredrain Date: Tue, 3 Sep 2024 09:34:25 +0800 Subject: [PATCH] feat: add windows json --- apps/dgiot/src/utils/dgiot_json.erl | 16 ++++++++++++++-- apps/dgiot_atomgit | 1 - 2 files changed, 14 insertions(+), 3 deletions(-) delete mode 160000 apps/dgiot_atomgit diff --git a/apps/dgiot/src/utils/dgiot_json.erl b/apps/dgiot/src/utils/dgiot_json.erl index 8c32ed2c..1b8eb7c5 100644 --- a/apps/dgiot/src/utils/dgiot_json.erl +++ b/apps/dgiot/src/utils/dgiot_json.erl @@ -55,7 +55,13 @@ encode(Term) -> -spec(encode(json_term(), encode_options()) -> json_text()). encode(Term, Opts) -> - to_binary(jiffy:encode(to_ejson(Term), Opts)). + case os:type() of + {win32,nt} -> +%% io:format("~s ~p ~p ~p ~n",[?FILE, ?LINE,Term,Opts]), + to_binary(jsx:encode(Term)); + _ -> + to_binary(jiffy:encode(to_ejson(Term), Opts)) + end. -spec(safe_encode(json_term()) -> {ok, json_text()} | {error, Reason :: term()}). @@ -77,7 +83,13 @@ decode(Json) -> decode(Json, [return_maps]). -spec(decode(json_text(), decode_options()) -> json_term()). decode(Json, Opts) -> - from_ejson(jiffy:decode(Json, Opts)). + case os:type() of + {win32,nt} -> +%% io:format("~s ~p ~p ~p ~n",[?FILE, ?LINE,Json,Opts]), + from_ejson(jsx:decode(Json, Opts)); + _ -> + from_ejson(jiffy:decode(Json, Opts)) + end. -spec(safe_decode(json_text()) -> {ok, json_term()} | {error, Reason :: term()}). diff --git a/apps/dgiot_atomgit b/apps/dgiot_atomgit deleted file mode 160000 index 6b224f6f..00000000 --- a/apps/dgiot_atomgit +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6b224f6f77eab84e2dc7d0d912780b6d132f4f0b