refactor: 全部实现移入 json 子包,attributes 改名 annotations
- src/Json*.cj → src/json/(包 simapi_serialization.json,对应 .NET System.Text.Json) - src/attributes → src/json/annotations/(包 simapi_serialization.json.annotations) - 根包 simapi_serialization 保留为 cjpm 扫描锚点,public import 重导出 json + annotations - 用法:import simapi_serialization.*(重导出)或 import simapi_serialization.json.* / .json.annotations.*
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/// 序列化时是否忽略 null/None 字段(默认 false:None 输出 null)
|
||||
public var ignoreNull: Bool = false
|
||||
|
||||
/// 枚举序列化为名字(默认 true;false 暂按名字输出,数字模式后续支持)
|
||||
public var enumAsString: Bool = true
|
||||
|
||||
/// 递归深度上限(默认 64)
|
||||
public var maxDepth: Int64 = 64
|
||||
|
||||
public init() {}
|
||||
|
||||
/// 默认选项实例
|
||||
public static let instance = JsonOption()
|
||||
}
|
||||
Reference in New Issue
Block a user