I have encountered a rather weird issue while trying to deserialize a simple json into an object of type D3Point
, which is used from a NuGet package.
The json looks like this:
string cJson = face["Edges"][0]["Coords"][0].ToString();
"{\"X\": 1262.6051066219518, \"Y\": -25972.229375190014, \"Z\": -299.99999999999994}"
And the deserialization attempt:
D3Point coord = JsonConvert.DeserializeObject<D3Point>(cJson);
After the above, coord's values are: {0;0;0}
.
Below is the D3Point
class.
public readonly struct D3Point : IEquatable<D3Point>
{
public static readonly D3Point Null = new D3Point(0, 0, 0);
public double X { get; }
public double Y { get; }
public double Z { get; }
public D3Point(double coordinateX, double coordinateY, double coordinateZ)
{
this.x = coordinateX;
this.y = coordinateY;
this.z = coordinateZ;
}
}
What could be the problem and how would I be able to fix it?