I'm getting JSON data like this from a third party API, which I cannot change:
{"ts":1234567890,"updates":[[4,104482,8209,2000000007,1462994403,"some text","some text again",{"from":"1337"}],[80,7,0],[7,2000000007,104481],[62,76706856,7]]}
I tried this code to deserialize it:
public class LongpollData
{
public ulong Ts { get; set; }
public List<Tuple<ApiEvent, int, ApiMask, ulong?, ulong?, string, string, FromInfo>> Updates { get; set; }
public class FromInfo
{
string From { get; set; }
}
public enum ApiEvent
{
delete = 0,
replace = 1,
setMessageFlags = 2,
resetMessageFlags = 3,
newMessage = 4,
readAllIn = 6,
readAllOut = 7,
friendIsOnline = 8,
friendIsOffline = 9,
chatChanged = 51,
userIsTyping = 61,
userIsTypingIn = 62,
userMadeCall = 70,
unreadMessagesCount = 80,
notificationSettingsChanged = 144,
}
[Flags]
public enum ApiMask
{
UNREAD = 1,
OUTBOX = 2,
REPLIED = 4,
IMPORTANT = 8,
CHAT = 16,
FRIENDS = 32,
SPAM = 64,
DELЕTЕD = 128,
FIXED = 256,
MEDIA = 512,
}
}
...
var UpdateData = JsonConvert.DeserializeObject<LongpollData>(webData);
but I'm getting an exception:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Tuple
8[VkKonekoBot.vkLongpollEvents+LongpollData+ApiEvent,System.Int32,VkKonekoBot.vkLongpollEvents+LongpollData+ApiMask,System.Nullable
1[System.UInt64],System.Nullable`1[System.UInt64],System.String,System.String,VkKonekoBot.vkLongpollEvents+LongpollData+FromInfo]' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath 'updates[0]', line 1, position 29.
What am I doing wrong?