HttpClient ReadAsStringAsync 四舍五入小数

HttpClient ReadAsStringAsync rounding decimal

在其中一个网络 API 控制器中,我有一个将请求发送给另一个第三方 API 的操作,在收到响应后它对 JSON 进行了一些操作收到数据,最后 returns 对前端应用程序的响应。示例代码如下:

using (var client = new HttpClient())
{
    var response = await client.GetAsync(_remoteServiceEndPoint + "student/" + id);
    if (response.IsSuccessStatusCode)
    {
        var contentString = await response.Content.ReadAsStringAsync();
        //do something with contents and finally return response to the caller
    }
}

现在,如果第三方发送一个 JSON 响应,其中包含一个数字 999999999999999.99 并且 ReadAsStringAsync 在上面的代码片段中执行,它将值更改为 10000000000000000.我不想要。

我想知道为什么 ReadAsStringAsync 会这样。

感谢@JessedeWit 指出这是 NewtonSoft 库的问题。引入 this SO 问题响应中提到的解决方法解决了问题。