【发布时间】:2019-04-08 20:08:07
【问题描述】:
当序列化一个仅具有布尔值的 JToken 时,第一个字母大写。由于那个大写字母,反序列化结果字符串失败。
以下测试因异常而失败:“解析值时遇到意外字符:T. Path '', line 0, position 0。”
using System;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using Xunit;
public class SimpleTests
{
[Fact]
public void TestJTokenBoolean()
{
var token = JToken.Parse("true");
token.Type.Should().Be(JTokenType.Boolean);
Action deserialize = () => JToken.Parse(token.ToString());
deserialize.Should().NotThrow();
}
}
做错了什么?或者可能是一个错误?
【问题讨论】: