Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何反序列化Json多个结果?_C# - Fatal编程技术网

C# 如何反序列化Json多个结果?

C# 如何反序列化Json多个结果?,c#,C#,我有如下字符串(一个字符串变量中有两行),如何在C中使用JsonConvert类将其分成两个字符串并进行反序列化# 您可以使用新行分隔符将字符串拆分为字符串数组,然后JSON反序列化每一行。要拆分字符串,可以使用以下方法 例如: string input = "... your input string ..."; string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyE

我有如下字符串(一个字符串变量中有两行),如何在C中使用JsonConvert类将其分成两个字符串并进行反序列化#


您可以使用新行分隔符将字符串拆分为字符串数组,然后JSON反序列化每一行。要拆分字符串,可以使用以下方法

例如:

string input = "... your input string ...";
string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines)
{
    // you could use a JSON serializer here to deserialize the line
    // and possibly add it to some result collection
}
string input = "... your input string ...";
string[] lines = input.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines)
{
    // you could use a JSON serializer here to deserialize the line
    // and possibly add it to some result collection
}