- JsonOption 删除 ignoreNull - JsonWriter.writeObject 不再按 null 跳过字段(只跳过 @JsonIgnore) - 删除不再使用的 isNoneValue - 测试:remark(None)→null 且保留;temp(@JsonIgnore) 唯一被排除
38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
/*
|
||
* 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()
|
||
}
|