【发布时间】:2010-06-07 10:35:55
【问题描述】:
嗨朋友我正在尝试将隐藏的控制字段反序列化为 JSON 对象,代码如下:
Dim settings As New Newtonsoft.Json.JsonSerializerSettings()
settings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
Return Newtonsoft.Json.JsonConvert.DeserializeObject(Of testContract)(txtHidden.Text, settings)
但我收到以下异常。 value cannot be null parameter name s: 我什至添加了以下几行,但仍然无法正常工作。请帮忙。
settings.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore
settings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
settings.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace
【问题讨论】:
-
除非你混淆了你的标题,否则答案是显而易见的,你给你的代码一个空值,这就是抛出 NullValueException 的原因
-
我之前使用的版本中没有抛出。我正在使用 JSON.net 3.5
-
这到底是怎么回事?你知道错误是在哪里引发的吗? (这个“s”参数是什么?它与您尝试反序列化的对象有关,还是与Json.Net有关?)