I'm using JSON.NET version 6.0.1 and here my code below
var text = await FileHelper.ReadFileAsync(folderSetting, fileName);
var items = await JsonConvert.DeserializeObjectAsync<ObservableCollection<ItemModel>>(text);
But my Visual Studio Warning
Warning 7 'Newtonsoft.Json.JsonConvert.DeserializeObjectAsync(string)' is obsolete: 'DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => DeserializeObject(value))'
The library authors decided that it was not the responsibility of the library to provide asynchronous wrappers and marked them obsolete. (see http://blogs.msdn.com/b/pfxteam/archive/2012/03/24/10287244.aspx). In future versions these methods will be removed. You should do something like this instead:
var result = await
Task.Factory.StartNew(() => JsonConvert.DeserializeObject<MyObject>(jsonText));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With