我该如何在JSON.NET中反序列化以下内容?(我想使用字符串)
我的JSON对象必须像这样吗?
["String1","String2","String3"]
我的JSON对象必须像这样吗?
["Name1":"Value1","Name2":"Value2","Name3":"Value3"]
["String1","String2","String3"]
["Name1":"Value1","Name2":"Value2","Name3":"Value3"]
string[] array = JsonConvert.DeserializeObject<String[]>("[\"String1\",\"String2\",\"String3\"]");
这里有一个完整的可用示例:
using System;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string[] array = JsonConvert.DeserializeObject<String[]>("[\"String1\",\"String2\",\"String3\"]");
foreach (string item in array)
Console.WriteLine(item);
}
}