Closed frankinstien closed 3 years ago
Is Class
a List<Guid>
?
Yes, it is.
The following works fine:
public class WordEntry
{
public List<Guid> Class { set; get; }
public List<int> EdgePaths { set; get; }
public List<int> RelatedWords { set; get; }
public String Word { set; get; }
public bool Plural { set; get; }
//public Tense TenseState { set; get; }
public Guid RootForm { set; get; }
public Guid ID { set; get; }
public Single UseFrequency { set; get; }
public List<int> PartsofSpeech { set; get; }
}
[Test]
public static void emptylist()
{
var s = "{ 'Class': ['K2JFO+FwG0CfeuTFE283AQ=='], 'EdgePaths': [-1537686140], 'RelatedWords': [], 'Word': 'Tum-ti-tum', 'Plural': false, 'TenseState': 'present', 'RootForm': 'AAAAAAAAAAAAAAAAAAAAAA==', 'ID': '78LPEHC0wkiQQu6DvX9wzQ==', 'UseFrequency': 0, 'PartsofSpeech': [] }";
var o = JSON.ToObject<WordEntry>(s.Replace("\'","\""));
}
The Json below is valid and was serialized by FastJson but I get a "Could not find token at index 0" error when I try to de-serialize it. Any ideas as to what can cause this?
{ "$types": { "CategoryModels.WordEntry, CategoryModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null": "1" }, "$type": "1", "Class": ["K2JFO+FwG0CfeuTFE283AQ=="], "EdgePaths": [-1537686140], "RelatedWords": [], "Word": "Tum-ti-tum", "Plural": false, "TenseState": "present", "RootForm": "AAAAAAAAAAAAAAAAAAAAAA==", "ID": "78LPEHC0wkiQQu6DvX9wzQ==", "UseFrequency": 0, "PartsofSpeech": [] }
` [DataContract] [Serializable] public class WordEntry { [DataMember] public List Class { set; get; }
[DataMember]
public List EdgePaths { set; get; }
[DataMember]
public List RelatedWords { set; get; }
[DataMember]
public String Word { set; get; }
[DataMember]
public bool Plural { set; get; }
[DataMember]
public Tense TenseState { set; get; }
[DataMember]
public Guid RootForm { set; get; }
[DataMember]
public Guid ID { set; get; }
[DataMember]
public Single UseFrequency { set; get; }
[DataMember]
public List PartsofSpeech { set; get; }
} `