I have this json file :
{
“transactions”:[
{
“type”:”deposit”,
“account_id”:123456789012345,
“amount”:20000.0
},
{
“type”:”deposit”,
“account_id”:555456789012345,
“amount”:20000.0
},
{
“type”:”payment”,
“account_id”:123456789012345,
“amount”:20000.0
},
{
“type”:”transfer”,
“from”:555456789012345,
“to”:123456789012345,
“amount”:20000.0
}
]
}
and I want to read this file with JSON.net.
I tried this code but it has some unhandeld errors :
var records = JsonConvert.DeserializeObject<List<Type>>(File.ReadAllText(FileAddress));
using (StreamReader SrFile = File.OpenText(FileAddress))
{
JsonSerializer Serializer = new JsonSerializer();
JsonAccount newJsonAccount = (JsonAccount)Serializer.Deserialize(SrFile, typeof(JsonAccount));
}
the error is :
An unhandled exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll
Additional information: Unexpected character encountered while parsing value: �. Path '', line 0, position 0
now it has this error :
Additional information: Error converting value "transactions" to type 'ImportAndExport.MainForm+JsonAccount'. Path '', line 1, position 14.
UPDATE 2 :
now the error is :
An unhandled exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll
Additional information: Invalid character after parsing property name. Expected ':' but got: t. Path '', line 2, position 7.
var records?