diff --git a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs index 60dbe45..2376614 100644 --- a/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs +++ b/Core Modules/WalletConnectSharp.Storage/FileSystemStorage.cs @@ -110,8 +110,23 @@ private async Task Load() await _semaphoreSlim.WaitAsync(); var json = await File.ReadAllTextAsync(FilePath, Encoding.UTF8); _semaphoreSlim.Release(); - Entries = JsonConvert.DeserializeObject>(json, - new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); + + try + { + Entries = JsonConvert.DeserializeObject>(json, + new JsonSerializerSettings() {TypeNameHandling = TypeNameHandling.Auto}); + } + catch (JsonSerializationException e) + { + // Move the file to a .unsupported file + // and start fresh + WCLogger.LogError(e); + WCLogger.LogError("Cannot load JSON file, moving data to .unsupported file to force continue"); + if (File.Exists(FilePath + ".unsupported")) + File.Move(FilePath + ".unsupported", FilePath + "." + Guid.NewGuid() + ".unsupported"); + File.Move(FilePath, FilePath + ".unsupported"); + Entries = new Dictionary(); + } } } }