If one serializes a Math.Net SparseVector it treats it as a List and returns:
[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,12.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
When one tries to Deserialize you get an error:
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Cannot create and populate list type MathNet.Numerics.LinearAlgebra.Double.SparseVector.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Utilities.CollectionUtils.CreateList(Type listType, Boolean& isReadOnlyOrFixedSize)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type)
at FSharp.JsonConsole.MyConsole.deserialize(String json, Type jsonType) in C:\Users\carlnol\Projects\FSharp.JsonConsole\FSharp.JsonConsole\MyConsole.fs:line 45
at FSharp.JsonConsole.MyConsole.Run[a](a args) in C:\Users\carlnol\Projects\FSharp.JsonConsole\FSharp.JsonConsole\MyConsole.fs:line 88
at FSharp.JsonConsole.Program.Main(String[] args) in C:\Users\carlnol\Projects\FSharp.JsonConsole\FSharp.JsonConsole\Program.fs:line 10
InnerException:
As a point of reference the JSON format using the DataContractJsonSerializer is:
{"<Count>k__BackingField":36,"_nonZeroIndices":[12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"_nonZeroValues":[12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"<NonZerosCount>k__BackingField":1}