我在 IIS 服务器上托管了一个 API。
我正在使用以下参数向 URI 发出请求。
{"CurrentTime":"2013-09-23 13:05:52",
"Measurement":[{"Comment":"Test Comment","RecordIdentifier":"7F54BF3C-6022-423B-8B8F-0121BA2AF516"}],
"Source":"ABC","Destination":"XYZ",
"FinalIdentifier":"058B5913-FAB9-4641-B02E-2729A02B5059"}
对于上述请求,我可以成功反序列化请求参数。注意“FinalIdentifier”和“Comment”参数的值。
但是,当请求像:
{"CurrentTime":"2013-09-23 13:05:52",
"Measurement":[{"Comment":"Âëīö","RecordIdentifier":"01CEBEAE-B99D-47B1-9C2D-1CB80069917B"}],
"Source":"ABC","Destination":"XYZ",
"FinalIdentifier":"058B5913-FAB9-4641-B02E-2729A02B5059"}
我也可以成功反序列化此请求,但“FinalIdentifier”参数的值正在获取Guid.Empty (00000000-0000-0000-0000-000000000000)
。这里注意第二个请求评论字段中的 Umlet 字符,它是一些德语字符(垃圾字符)。
那么,垃圾字符会影响GUID
价值吗?但是,还要注意两个请求中“RecordIdentifier”值的值。“RecordIdentifier”没有问题。
那么问题出在哪里?
我有下面的请求和解析实体。
public class Measurement
{
public string Comment { get; set; }
public Guid RecordIdentifier { get; set; }
}
public class MeasurentEntityMain
{
public List<Measurement> measurement { get; set; }
public Guid FinalIdentifier { get; set; }
public string Source { get; set; }
public string Destination { get; set; }
}
以上两个请求我都从提琴手那里捕获。在 API 方面,我已经通过调试对其进行了测试。
那么,为什么这个 Guid 字段设置为空字段。
我正在使用 JSON 序列化和反序列化。