34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
/*
|
|||
|
|
* Copyright (c) 2025 SimcuTeam. All rights reserved.
|
||
|
|
* 对齐 .NET System.Text.Json.Serialization 特性:
|
||
|
|
* - [JsonPropertyName("xxx")] → @JsonPropertyName["xxx"] 指定字段的 JSON 名称
|
||
|
|
* - [JsonIgnore] → @JsonIgnore 序列化/反序列化时忽略该字段
|
||
|
|
*
|
||
|
|
* 参考仓颉官方注解用法(std.reflect 运行时读取):
|
||
|
|
* https://docs.cangjie-lang.cn/en/docs/1.0.0/libs/std/reflect/reflect_samples/annotation.html
|
||
|
|
*/
|
||
|
|
|
||
|
|
package simapi_serialization.attributes
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 指定字段的 JSON 名称(对齐 .NET JsonPropertyNameAttribute)。
|
||
|
|
* 用法:@JsonPropertyName["user_name"] public var _username: String = ""
|
||
|
|
*/
|
||
|
|
@Annotation[target: [MemberVariable, MemberProperty]]
|
||
|
|
public class JsonPropertyName {
|
||
|
|
public let name: String
|
||
|
|
|
||
|
|
public const init(name: String) {
|
||
|
|
this.name = name
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 标记字段不做 JSON 处理(对齐 .NET JsonIgnoreAttribute)。
|
||
|
|
* 用法:@JsonIgnore public var _temp: String = ""
|
||
|
|
*/
|
||
|
|
@Annotation[target: [MemberVariable, MemberProperty]]
|
||
|
|
public class JsonIgnore {
|
||
|
|
public const init() {}
|
||
|
|
}
|