src.nth.io/

summaryrefslogtreecommitdiff
path: root/src/json.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.ts')
-rw-r--r--src/json.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/json.ts b/src/json.ts
new file mode 100644
index 0000000..53ab378
--- /dev/null
+++ b/src/json.ts
@@ -0,0 +1,8 @@
+/**
+ * JSON serialization for command output. 64-bit values (node IDs, Matter
+ * microsecond timestamps) are bigints internally and render as decimal
+ * strings, never as lossy JavaScript numbers.
+ */
+export function toJsonString(value: unknown): string {
+ return JSON.stringify(value, (_key, inner) => (typeof inner === "bigint" ? inner.toString() : inner), 2);
+}