更新时间:2023-01-17 21:51:17
首先,您必须弄清楚API返回的内容.
First of all you have to figure out what your API returns.
现在,您正在尝试解析jsonToObj
Arrays
(List<jsonToObj[]>
)的List
.您必须决定使用API现在提供的jsonToObj[]
或List<jsonToObj>
还是简单的jsonToObj
:
Right now you're trying to parse a List
of jsonToObj
Arrays
(List<jsonToObj[]>
). You have to decide whether to use a jsonToObj[]
or List<jsonToObj>
or a simple jsonToObj
which your API provides now:
var a = JsonConvert.DeserializeObject<jsonToObj>(richTextBox1.Text);
但是这会引发:
JSON整数918819437284对于Int32而言太大或太小.路径"messages [0] .recipient",第25行,位置33."
JSON integer 918819437284 is too large or small for an Int32. Path 'messages[0].recipient', line 25, position 33."
因此请确保为此使用Long
.
public class messages
{
public string id { get; set; }
public long recipient { get; set; }
}
此外,如果需要以下信息,您可以将inDND
添加到您的jsonToObj
类中:
Furthermore you can add inDND
to your jsonToObj
class if you need the info:
public class jsonToObj
{
...
public string[] inDND { get; set; }
...
}
将JSON转换为对象失败-无法将当前JSON对象反序列化为System.Collections.Generic.List
无法将当前 JSON 对象(例如 {“name":“value"})反序列化为类型“System.Collections.Generic.List"1
无法将当前 JSON 对象(例如 {“name":“value"})反序列化为“System.Collections.Generic.List"类型
无法将当前的JSON对象反序列化(例如{“name”:“value”})转换为“System.Collections.Generic.List”1类型
'无法将当前JSON对象(例如{" Name":" value"})反序列化为类型'system.collections.generic.list`1 ...
无法将当前JSON对象(例如{"name":"value"})反序列化为"System.Collections.Generic.List"类型
JSON.Net-无法将当前json对象(例如{"name":"value"})反序列化为类型'system.collections.generic.list`1