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;
}
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);
}
"SizeRelative": {
"X": 224.0,
"Y": 63.9999847
},
"SizeRelative": "384, 64",
JSON.NET uses an associated TypeConverter if that is available on the class/struct, this was originally only available in the .Net full framework.
For .Net core and UWP it will be added in the next release, as a part of .NET Standard 2.0, so if you are using Json.NET in both UWP and desktop, that is probably the issue.
Check for a TypeConverter on your class/struct. Removing it should make JSON.NET fall-back to the default serializer which is probably what you are getting on your UWP builds.