Found one case where Newtonsoft.Json deserializes more correctly (#80)

* an operation is returning a special escape "\/Date(int)\/"
This commit is contained in:
Louis DeJardin 2018-10-18 00:30:53 -07:00 коммит произвёл GitHub
Родитель 9dddefbf1f
Коммит 9c10edd0d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -109,7 +110,30 @@ namespace Microsoft.Atlas.CommandLine.JsonClient
// using (var reader = new StringReader(responseBody))
using (var reader = new StreamReader(await response.Content.ReadAsStreamAsync()))
{
jsonResponse.body = _deserializer.Deserialize<TResponse>(reader);
try
{
jsonResponse.body = _deserializer.Deserialize<TResponse>(reader);
}
catch (YamlDotNet.Core.SyntaxErrorException)
{
var failed = true;
try
{
var responseBody = await response.Content.ReadAsStringAsync();
var temporary = Newtonsoft.Json.JsonConvert.DeserializeObject(responseBody);
var json = Newtonsoft.Json.JsonConvert.SerializeObject(temporary);
jsonResponse.body = _deserializer.Deserialize<TResponse>(json);
failed = false;
}
catch
{
}
if (failed)
{
throw;
}
}
}
// Information is added to secret tracker as soon as possible