In C#, I'm wrapping primitive types to track what the primitive represents. Here's an example:
class Meters {
public readonly float Value;
public Meters(float v) { Value = v; }
}
I then compose these types into objects:
class Box {
public Meters Width { get; set; }
public Meters Height { get; set; }
}
Using Json.net, I need to deserialize a Box from json data that look like this:
{
"Width": 3.23,
"Height": 2.0
}
Can this be done without changing the json to "Width": { "Value": 3.23 } and without repeated, boilerplate code for every type like Meters?
Thanks.