假设我有一个json:
{"firstName": "Mike", "age": 35}
还有一个类:
export class Person {
private firstName: StringProperty = new SimpleStringProperty();
private age: IntegerProperty = new SimpleIntegerProperty();
public constructor() {
//does nothing
}
public setFirstName(firstName: string): void {
this.firstName.set(firstName);
}
public getFirstName(): string {
return this.firstName.get();
}
public setAge(age: number): void {
this.age.set(age);
}
public getAge(): number {
return this.age.get();
}
}
我可以在转换到/从 json 时让类转换器使用 getter/setter 吗?