When deserializing "malformed", non-round-trip JSON where unexpected values are encountered, a stack overflow occurs.
For example, when deserializing the following JSON to an object where both properties are Power
{
"ChargePower": {
"Unit": "PowerUnit.Kilowatt",
"Value": 11.0
},
"DischargePower": 12.0
}
then the latter triggers an infinite loop in this code:
| if(valueUnit==null) |
| { |
| returntoken.ToObject<IQuantity>(serializer); |
| } |
I guess there could be a nicer way of handling this. Maybe interpreting the value as the base unit of Power or throwing an exception?
Also, thanks for making this great library! 👍
When deserializing "malformed", non-round-trip JSON where unexpected values are encountered, a stack overflow occurs.
For example, when deserializing the following JSON to an object where both properties are
Powerthen the latter triggers an infinite loop in this code:
UnitsNet/UnitsNet.Serialization.JsonNet/UnitsNetIQuantityJsonConverter.cs
Lines 66 to 69 in 47cdd1f
I guess there could be a nicer way of handling this. Maybe interpreting the value as the base unit of
Poweror throwing an exception?Also, thanks for making this great library! 👍