Files
serialization-cj/src/json/JsonOption.cj
T
xrain 67da604294 refactor: 移除 ignoreNull 选项——非 @JsonIgnore 字段一律输出,None 输出 null
- JsonOption 删除 ignoreNull
- JsonWriter.writeObject 不再按 null 跳过字段(只跳过 @JsonIgnore)
- 删除不再使用的 isNoneValue
- 测试:remark(None)→null 且保留;temp(@JsonIgnore) 唯一被排除
2026-08-17 11:21:56 +08:00

38 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* Copyright (c) 2025 SimcuTeam. All rights reserved.
* JsonOption:序列化选项(对齐 .NET JsonSerializerOptions)。
*/
package simapi_serialization.json
/**
* 属性命名策略(对齐 .NET JsonNamingPolicy)。
*/
public enum PropertyNamingPolicy {
/// 字段名原样(_username → _username
| None
/// 去前导下划线 + 首字母小写(_username → username,对齐 simapi/soulsoft 默认)
| CamelCase
/// 蛇形(userName → user_name_username → username
| SnakeCase
}
/**
* 序列化选项。
*/
public class JsonOption {
/// 属性命名策略(默认 CamelCase)
public var propertyNamingPolicy: PropertyNamingPolicy = PropertyNamingPolicy.CamelCase
/// 枚举序列化为名字(默认 true;false 暂按名字输出,数字模式后续支持)
public var enumAsString: Bool = true
/// 递归深度上限(默认 64)
public var maxDepth: Int64 = 64
public init() {}
/// 默认选项实例
public static let instance = JsonOption()
}