I've got an ASP.NET MVC application that serializes a number of different objects using Json.NET. However, I've recently had to change how some of these objects work, principally converting a number of its properties from type double
to type double[]
.
This has worked fine for new instances of that object, but when deserializing the object I get the following JsonSerializationException
:
Error converting value 0 to type 'System.Double[]'. Path 'Results[1].Data.BufferMinimumTime', line 1, position 1102.
This error was expected, but I'm unsure of how to handle this. Ideally, all past results could be deserialized and converted into double[]
objects (the conversion is fairly simple - the double will always be the same size, and given the double value
, the array would take the form {value, 0d, value}
), but I'm not sure where to insert this.
I've added a method with the System.Runtime.Serialization.OnDeserializedAttribute
attribute to try and catch this before the exception is thrown, with no success.
If anyone has any suggestions to convert this model before it fails, it would be much appreciated.