I have a struct, Vector2 that when serialized to JSON produces a different outpout on different platforms.
Struct I am serializing:
#if XNADESIGNPROVIDED
[System.ComponentModel.TypeConverter(typeof(Microsoft.Xna.Framework.Design.Vector2TypeConverter))]
#endif
[DataContract]
[DebuggerDisplay("{DebugDisplayString,nq}")]
[DebuggerStepThrough]
public struct Vector2 : IEquatable<Vector2>
{
[DataMember]
public float X;
[DataMember]
public float Y;
}
Serialization
This struct is part of a class, that is part of a collection. This code is included on both platforms, and run on both platforms.
private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore };
public string ToJson()
{
return JsonConvert.SerializeObject(this, JsonSerializerSettings);
}
public static MenuEntryCollection FromJson(string in_Data)
{
return JsonConvert.DeserializeObject<MenuEntryCollection>(in_Data);
}
Result from UWP Serializer:
"SizeRelative": {
"X": 224.0,
"Y": 63.9999847
},
Result from Desktop Seralizer:
"SizeRelative": "384, 64",
Using Newtonsoft Json.net, 10.0.3
Why is the output different? And why can one, not load the other?