diff options
author | kaiwu <kaiwu2004@gmail.com> | 2024-07-17 17:40:35 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2024-07-17 17:40:35 +0800 |
commit | 3c054eec881b078aaa51cbfe650cbf8f82df6619 (patch) | |
tree | aaef4199be96cd55d0f2129738a45e024ab6c07a | |
parent | 412e26df53f77ff1dd2fe864deb1e1417d12e213 (diff) | |
download | wechat-3c054eec881b078aaa51cbfe650cbf8f82df6619.tar.gz wechat-3c054eec881b078aaa51cbfe650cbf8f82df6619.zip |
use gleam json
-rw-r--r-- | gleam.toml | 1 | ||||
-rw-r--r-- | manifest.toml | 4 | ||||
-rw-r--r-- | src/wechat/object.gleam | 3 | ||||
-rw-r--r-- | src/wechat_ffi.mjs | 4 |
4 files changed, 11 insertions, 1 deletions
@@ -18,6 +18,7 @@ gleam = ">= 1.2.0" gleam_stdlib = ">= 0.34.0 and < 2.0.0" gleam_javascript = ">= 0.11.0 and < 1.0.0" gleam_json = ">= 2.0.0 and < 3.0.0" +json = ">= 1.4.1 and < 2.0.0" [dev-dependencies] gleeunit = ">= 1.0.0 and < 2.0.0" diff --git a/manifest.toml b/manifest.toml index 0817c7a..b1b31fc 100644 --- a/manifest.toml +++ b/manifest.toml @@ -6,10 +6,12 @@ packages = [ { name = "gleam_json", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB10B0E7BF44282FB25162F1A24C1A025F6B93E777CCF238C4017E4EEF2CDE97" }, { name = "gleam_stdlib", version = "0.39.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "2D7DE885A6EA7F1D5015D1698920C9BAF7241102836CE0C3837A4F160128A9C4" }, { name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" }, + { name = "json", version = "1.4.1", build_tools = ["mix"], requirements = [], otp_app = "json", source = "hex", outer_checksum = "9ABF218DBE4EA4FCB875E087D5F904EF263D012EE5ED21D46E9DBCA63F053D16" }, ] [requirements] gleam_javascript = { version = ">= 0.11.0 and < 1.0.0" } -gleam_json = { version = ">= 2.0.0 and < 3.0.0"} +gleam_json = { version = ">= 2.0.0 and < 3.0.0" } gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" } gleeunit = { version = ">= 1.0.0 and < 2.0.0" } +json = { version = ">= 1.4.1 and < 2.0.0"} diff --git a/src/wechat/object.gleam b/src/wechat/object.gleam index 42b5178..1b2cd7c 100644 --- a/src/wechat/object.gleam +++ b/src/wechat/object.gleam @@ -20,6 +20,9 @@ pub type WechatCallback = fn() -> Nil @external(javascript, "../wechat_ffi.mjs", "obj_new") pub fn new() -> JsObject +@external(javascript, "../wechat_ffi.mjs", "obj_stringify") +pub fn stringify() -> String + @external(javascript, "../wechat_ffi.mjs", "obj_dynamic") pub fn dynamic(o: JsObject) -> Dynamic diff --git a/src/wechat_ffi.mjs b/src/wechat_ffi.mjs index 5ef4574..0d108c2 100644 --- a/src/wechat_ffi.mjs +++ b/src/wechat_ffi.mjs @@ -48,6 +48,10 @@ export function obj_new() { return {}; } +export function obj_stringify(o) { + return JSON.stringify(o); +} + export function obj_dynamic(o) { return o; } |