While the title is straight to the point, the problem has a weird aspect as well. So I have two solutions; D4T
and Jangers
. I am trying the same (de)serialization code in both solutions. I also made sure that all references are the same and that the object used are all in the same namespaces and everything.
Now, in Jangers
I use the following code for serialization:
PropertySet propertySet = new PropertySet();
propertySet.SetProperty("T", new Vector(12, 13, 14));
//PropertySet
var serializePropertySet = Newtonsoft.Json.JsonConvert.SerializeObject(propertySet, Formatting.Indented);
PropertySet deserializePropertySet = Newtonsoft.Json.JsonConvert.DeserializeObject<PropertySet>(serializePropertySet);
The json in serializePropertySet
is the following:
{
"$type": "Core.PropertySet, Connectivity.DataModel",
"T": {
"X": 12.0,
"Y": 13.0,
"Z": 14.0
}
}
And it also deserializes properly.
However, if I try the exact same code in D4T
, the X
, Y
and Z
are empty and they seem to be arrays.
{
"$type": "Core.PropertySet, Connectivity.DataModel",
"T": {
"$type": "Newtonsoft.Json.Linq.JObject, Newtonsoft.Json",
"X": {
"$type": "Newtonsoft.Json.Linq.JValue, Newtonsoft.Json",
"$values": []
},
"Y": {
"$type": "Newtonsoft.Json.Linq.JValue, Newtonsoft.Json",
"$values": []
},
"Z": {
"$type": "Newtonsoft.Json.Linq.JValue, Newtonsoft.Json",
"$values": []
}
}
}
What could be the cause? How can I make a workaround to make it work in the second solution as well?
EDIT: This is how it looks when debugging: