0

私は以下のような文字列を持っています (2 行は 1 つの文字列変数にあります)、2 つの文字列に分割し、C# で JsonConvert クラスを使用して逆シリアル化するにはどうすればよいですか?

 {"operation":"waiting","wait":12121212}
 {"operation":"result","firstname":"bill", "lastname":"last"}
4

1 に答える 1

2

新しい行区切り記号を使用して文字列を文字列の配列に分割し、JSON で各行を逆シリアル化できます。文字列を分割するには、メソッドを使用できますSplit

例えば:

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
}
于 2013-02-16T14:35:06.120 に答える