I am trying to use OneSignal API. My problem isn't specific to OneSignal but I think that referencing it might make it easier to explain.
OneSignal is an SAAS for delivering notifications to phones and browsers and I am trying to hook it up to my server. The problem is that the request to OneSignal API returns:
{
"id": "458dcec4-cf53-11e3-add2-000c2940e62c",
"recipients": 5
}
or
{
"errors": {
"invalid_player_ids" : ["5fdc92b2-3b2a-11e5-ac13-8fdccfe4d986", "00cb73f8-5815-11e5-ba69-f75522da5528"]
}
}
or
{
"id": "",
"recipients": 0,
"errors": ["All included players are not subscribed"]
}
while I am trying to deserialize the request using DataContracts
and DataContractJsonSerializer
.
My question is: how do I parse a JSON where a property can be empty, can be an object or an array of strings? Is there a way to do that using just standard DataContract
attributes or do I have to write my own serializer? If so, could you point me to some resources or to any tutorial since I couldn't find anything resolving my problem so far?