Share
Newtonsoft.Json.JsonSerializationException: ‘Cannot deserialize the current JSON object
Soru
Merhaba JsonConvert yaparken aşağıdaki hatayı alıyorum. Parse işleminde nerede hata yapıyorum arkadaşlar.
Newtonsoft.Json.JsonSerializationException: ‘Cannot deserialize the current JSON object (e.g. {“name”:”value”}) into type ‘System.Collections.Generic.List`1[CRobot.Form1+Fiyat]’ because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path ‘symbol’, line 1, position 10.’
devam ediyor
0
c#
1 sene
1 Cevap
886 gösterim
0
Cevap ( 1 )
Merhaba aşağıdaki şekilde denermisiniz.
List<fiyat> datalist = JsonConvert.DeserializeObject<List<fiyat>>(jsonstring);
yerine
fiyat datalist = JsonConvert.DeserializeObject<fiyat>(jsonstring);
şeklinde bir kullanımla bu hatadan kurtulabilirsiniz.