子类化UIButton(JSON.NET)时无法反序列化JSON

时间:2013-03-29 19:02:34

标签: ios json mono xamarin.ios json.net

我正在使用json.net来解析一些属性。 我现在正试图将它用于一个源自UIButton的类:

    public class JsonButton : UIButton
{
    public String ItemId = "";

    public JsonButton ()
    {
    }
}

我收到了以下错误:

  

无法将JSON对象反序列化为“MyApplication.JsonButton”类型。

     

at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(Newtonsoft.Json.JsonReader reader,System.Type objectType,Newtonsoft.Json.Serialization.JsonContract contract,Newtonsoft.Json.Serialization.JsonProperty member,System.Object existingValue)[ 0x003a4]在/Users/xxx/Projects/_MonoTouchLibraries/Newtonsoft.Json-master/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:441

如果我从我自己的类

中继承它,JSON正在运行没有问题
public class JsonButton : MyOwnClass
{
    public String ItemId = "";

    public JsonButton ()
    {
    }
}

测试JSON非常简单(正如上面所说的那样):

{
"ItemId": "16"
}

有什么想法吗?

0 个答案:

没有答案