.NET で ServiceStack.Text を使用しています。次のインスタンスをシリアル化したい:
IDictionary<string, ResourceSpec>
ResourceSpec は次のとおりです。
public class ResourceSpec
{
public string TypeName
{
get;
set;
}
public HashSet<Property> Properties
{
get;
set;
}
}
次の形式にシリアル化されます。
{1:{"TypeName":"channel","Properties":[audio,video]},2:{"TypeName":"channel","Properties":[audio,video,encrypted]}}
私がそれをデシリアライズしようとすると:
JsonSerializer.DeserializeFromStream<IDictionary<string, ResourceSpec>>(file);
例外が発生します:
SerializationException: "Type definitions should start with a '{', expecting serialized type 'ResourceSpec', got string starting with: Properties"
何が問題なのですか?