My JSON looks like:
[
{
"Key": {
"PatientName": "Hans Gerd",
"Alter": 81,
"Geschlecht": "M",
"Zimmernummer": 1,
"PatientenLiegeplatz": 0,
"IsDummyData": false
},
"Value": {
"Puls": 0,
"Temperatur": 0.0,
"Systole": 0,
"Diastole": 0,
"DictationText": "",
"Timestamp": "2021.05.24 12:31:06"
}
}
]
Serialization:
string json = JsonConvert.SerializeObject(saveObj.CareRoutineDataDictionary.ToArray(), Formatting.Indented);
How to Deserialize it? I have tried so much and it doesn't work. Common error Messages:
Unexpected character encountered while parsing value
If I try to do:
Dictionary<BasicPatientData, CareRoutineData> data = JsonConvert.DeserializeObject<Dictionary<BasicPatientData, CareRoutineData>>(File.ReadAllText(SaveFilePath));
I get an error:
JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[BasicPatientData,CareRoutineData]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Can anyone help?