我正在使用Json.net 4.5。我正在使用JsonConverter将数据从一个版本转换为另一个版本。
版本1
public class AV1
{
public string PNr { get; set; } // "x253yN-69Uj"
}
版本2
public class AV2
{
public string FirstNr { get; private set; } // "x253yN"
public string LastNr { get; private set; } // "69Uj"
public void SetFirstAndLastNr(string a, string b, string c)
{
//Logic to set the values of FirstNr and LastNr
}
}
在派生的JsonConverter中,我正在创建
AV2
类的实例。但由于属性现在是只读属性,我应该如何设置这些属性的值? Json.net提供了任何方法来执行此操作吗?还是我必须使用反射?
SetFirstAndLastNr
中,参数a
、b
和c
分别代表什么意思? - carlosfigueira