From 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 四月 2026 11:46:41 +0800
Subject: [PATCH] 推送
---
node_modules/ajv/lib/compile/jtd/serialize.ts | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/node_modules/ajv/lib/compile/jtd/serialize.ts b/node_modules/ajv/lib/compile/jtd/serialize.ts
index 1d22882..42a47cf 100644
--- a/node_modules/ajv/lib/compile/jtd/serialize.ts
+++ b/node_modules/ajv/lib/compile/jtd/serialize.ts
@@ -228,8 +228,19 @@
gen.add(N.json, _`${useFunc(gen, quote)}(${data})`)
}
-function serializeNumber({gen, data}: SerializeCxt): void {
- gen.add(N.json, _`"" + ${data}`)
+function serializeNumber({gen, data, self}: SerializeCxt): void {
+ const condition = _`${data} === Infinity || ${data} === -Infinity || ${data} !== ${data}`
+
+ if (self.opts.specialNumbers === undefined || self.opts.specialNumbers === "fast") {
+ gen.add(N.json, _`"" + ${data}`)
+ } else {
+ // specialNumbers === "null"
+ gen.if(
+ condition,
+ () => gen.add(N.json, _`null`),
+ () => gen.add(N.json, _`"" + ${data}`)
+ )
+ }
}
function serializeRef(cxt: SerializeCxt): void {
--
Gitblit v1.9.3