35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
/*
|
||
* Copyright (c) 2025 SimcuTeam. All rights reserved.
|
||
* 序列化注解(对齐 .NET System.Text.Json.Serialization 特性):
|
||
* - [JsonPropertyName("xxx")] → @SerializerPropertyName["xxx"] 指定字段的序列化名称
|
||
* - [JsonIgnore] → @SerializerIgnore 序列化/反序列化时忽略该字段
|
||
*
|
||
* 设计决策:本库序列化/反序列化只处理「var 成员变量」(std.reflect 的 instanceVariables),
|
||
* 不处理 prop 属性(instanceProperties)。因此注解 target 仅限 MemberVariable:
|
||
* 标到 prop 上会直接编译报错,避免「标了但不生效」的静默陷阱。
|
||
*/
|
||
|
||
package simcu::serialization.common
|
||
|
||
/**
|
||
* 指定字段的序列化名称(对齐 .NET JsonPropertyNameAttribute)。
|
||
* 用法:@SerializerPropertyName["user_name"] public var _username: String = ""
|
||
*/
|
||
@Annotation[target: [MemberVariable]]
|
||
public class SerializerPropertyName {
|
||
public let name: String
|
||
|
||
public const init(name: String) {
|
||
this.name = name
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 标记字段不做序列化处理(对齐 .NET JsonIgnoreAttribute)。
|
||
* 用法:@SerializerIgnore public var _temp: String = ""
|
||
*/
|
||
@Annotation[target: [MemberVariable]]
|
||
public class SerializerIgnore {
|
||
public const init() {}
|
||
}
|