且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法反序列化当前的JSON数组(例如[1,2,3])入式

更新时间:2021-09-15 21:59:50

它看起来像字符串包含在一个单一的 MyStok 对象的数组。如果从输入的两端去掉括号,你应该能够反序列化数据作为单个对象:

It looks like the string contains an array with a single MyStok object in it. If you remove square brackets from both ends of the input, you should be able to deserialize the data as a single object:

MyStok myobj = JSON.Deserialize<MyStok>(sc.Substring(1, sc.Length-2));

您也可以反序列化数组到 MyStok 对象的列表,并采取在目标指数为零。

You could also deserialize the array into a list of MyStok objects, and take the object at index zero.

var myobjList = JSON.Deserialize<List<MyStok>>(sc);
var myObj = myobjList[0];