I have a cross-platform Xamarin.Forms app that uses Json.Net to serialize and deserialize a class JMessage
, which was taken from another question on the site. The class looks like this:
public class JMessage
{
public Type Type { get; set; }
public JToken Value { get; set; }
public static JMessage FromValue<T>(T value)
{
return new JMessage { Type = typeof(T), Value = JToken.FromObject(value) };
}
public static string Serialize(JMessage message)
{
return JToken.FromObject(message).ToString();
}
public static JMessage Deserialize(string data)
{
return JToken.Parse(data).ToObject<JMessage>();
}
}
Everything is fine and dandy in the UWP and iOS versions of the app and nothing breaks. However, the Android version only serializes the Value
property and completely ignores the Type
property, causing things to break when the JMessage
is deserialized. For example:
{
"Value":{
serialized properties go here...
}
}
This seems to be a bug that spans across all Android devices, as I've tested it on 3 different Android devices, plus an emulator. The JMessage
used to serialize and deserialize just fine so I'm not entirely sure what's happening now. Any answers?