DatacontractJsonSerializer can deserialize the following just fine, on both
PC and M4A:
"{\"CallUpdates\":[],\"Changes\":[{\"CallReference\":907,\"Changes\":[{\"Key\":\"deflectAllowed\",\"Value\":true},{\"Key\":\"takeAllowed\",\"Value\":true}],\"Line\":\"3453\"}],\"EndedCalls\":[],\"Line\":\"3453\",\"NewCalls\":[{\"CallReference\":907,\"CallState\":1,\"Capabilities\":null,\"Correlator\":null,\"CustomActionNumber\":\"4771\",\"CustomActionParameter\":null,\"E164Number\":\"4771\",\"Line\":\"3453\",\"LookedUpName\":null,\"Name\":\"WISSLER
Patrick\",\"Number\":\"4771\",\"TelephonicState\":3}]}"
But, swap out Key and Value in the dictionaries, and things go wrong on M4A:
"{\"CallUpdates\":[],\"Changes\":[{\"Changes\":[{\"Value\":true,\"Key\":\"deflectAllowed\"},{\"Value\":true,\"Key\":\"takeAllowed\"}],\"CallReference\":907,\"Line\":\"3453\"}],\"NewCalls\":[{\"Name\":\"WISSLER
Patrick\",\"CustomActionParameter\":null,\"LookedUpName\":null,\"CallReference\":907,\"CustomActionNumber\":\"4771\",\"Correlator\":null,\"Number\":\"4771\",\"TelephonicState\":3,\"Capabilities\":null,\"Line\":\"3453\",\"E164Number\":\"4771\",\"CallState\":1}],\"EndedCalls\":[],\"Line\":\"3453\"}"
As you can see, the only difference is that the latter string has Key and
Value swapped in the arrays.
Data Contract definition can be seen here:
https://bugzilla.xamarin.com/show_bug.cgi?id=6721
Other than the horrible approach of swapping keys and values in incoming
data, does anyone have an alternative? I already tried ServiceStack.Text's
FromJson extension
(received.FromJson<ClientInterface.CallStateChange>()) to no avail, and
RestSharp's JsonDeserializer (I already have both my project - ServiceStack
works for most other data, including enums (where RestSharp fails - until
this (https://github.com/restsharp/RestSharp/pull/310) is accepted), but it
doesn't stand a chance (and it doesn't like my CallStateChange class
either).
Regards
Stephan
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Dictionary-Deserialization-with-DataContractJsonSerializer-tp5711594.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid