Skip to content

Stack overflow when deserializing unexpected JSON values #1003

Closed
@Muximize

Description

@Muximize

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)
{
return token.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! 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions