私はJson.NETバージョン4.5を使用していますが、Json.Netは非常に初めてです。
問題:Json.NETでクラスのバージョン管理をサポートする方法を知る必要があります。
例:以下の例に示すように、2番目のバージョンにEmployeeDetailクラスがあり、NameプロパティはFirstNameとLastNameに分割されています。単一のアドレスがアドレスになります。
オブジェクトの逆シリアル化中に下位互換性を提供するためにカスタムJsonConverterを使用しようとしましたが、以下の例に示すように、インターフェイスをConcreteTypeにマップする一般的なカスタム作成JsonConverterをすでに使用しているため、複数のコンバーターを使用する際に問題が発生しました。
// Employee Detail Version 1.0
[JsonObject()]
public class EmployeeDetail
{
public EmployeeDetail()
{
}
public EmployeeDetail( string name )
{
Name = name;
}
[JsonProperty]
public string Name { get; set; }
[JsonConverterAttribute( typeof( CustomObjectCreationConverter<iAddress, Address> ) )]
public iAddress Address { get; set; }
}
// Employee Detail Version 2.0
[JsonObject()]
public class EmployeeDetail
{
public EmployeeDetail()
{
}
public EmployeeDetail( string firstName, string lastName )
{
FirstName = firstName;
LastName = lastName;
}
[JsonProperty]
public string FirstName { get; set; }
[JsonProperty]
public string LastName { get; set; }
[JsonConverterAttribute( typeof( CustomArrayCreationConverter<iAddress, Address> ) )]
public IEnumerable<iAddress> Addresses { get; set; }
}