I have a machine-generated class MyData
which has sbyte
members. The actual class is long and not very readable, but here is a fragment of it:
class MyData
{
private sbyte _MuxControl;
public sbyte MuxControl
{
get { return _MuxControl; }
set { __isset.MuxControl = true; this._MuxControl = value; }
}
}
The corresponding simplified JSON looks like this:
[
{
"MuxControl": 0xAA
}
]
I am attempting to deserialize like this:
var deserialized = JsonConvert.DeserializeObject<List<MyData>>(JsonStr);
Some values exceed sbyte
range, for example 0xAA
. As a result, exceptions are thrown. When I change the value to 0x1
, for example, it works.
I can not touch the code of MyData
. It's machine-generated. Is there a conversion setting, override or some other way to get these values to deserialize properly into sbyte
?