From de875234e4108f297ca6f22a507b3051b642d367 Mon Sep 17 00:00:00 2001 From: xRain Date: Mon, 17 Aug 2026 11:12:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=91=BD=E5=90=8D=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E4=B8=8D=E5=89=A5=E9=99=A4=E5=89=8D=E5=AF=BC=E4=B8=8B=E5=88=92?= =?UTF-8?q?=E7=BA=BF=EF=BC=88=5Fname=20=E5=8E=9F=E6=A0=B7=E8=BE=93?= =?UTF-8?q?=E5=87=BA=20=5Fname=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - applyNamingPolicy 不再去掉字段名前导 _,策略只影响字母大小写 - @JsonPropertyName 仍可覆盖(_alias → user_alias) - 测试改为 _ 前缀字段并验证原样输出 --- src/json/ReflectionCache.cj | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/json/ReflectionCache.cj b/src/json/ReflectionCache.cj index a3bfeed..3fd8ca3 100644 --- a/src/json/ReflectionCache.cj +++ b/src/json/ReflectionCache.cj @@ -78,16 +78,14 @@ public class ReflectionCache { /** * 应用属性命名策略。 + * 说明:不剥除字段名前导下划线——`_name` 原样输出 `_name`; + * 策略只影响字母大小写(CamelCase 首字母小写、SnakeCase 大写转下划线)。 */ public static func applyNamingPolicy(fieldName: String, policy: PropertyNamingPolicy): String { - var name = fieldName - while (name.startsWith("_")) { - name = name[1..] - } match (policy) { - case PropertyNamingPolicy.None => name - case PropertyNamingPolicy.CamelCase => toCamelCase(name) - case PropertyNamingPolicy.SnakeCase => toSnakeCase(name) + case PropertyNamingPolicy.None => fieldName + case PropertyNamingPolicy.CamelCase => toCamelCase(fieldName) + case PropertyNamingPolicy.SnakeCase => toSnakeCase(fieldName) } }