我试过
了JObject obj = new JObject();
obj["item1"] = new string[] {"a","b"};
并得到了
Cannot implicitly convert type 'string[]' to 'Newtonsoft.Json.Linq.JToken'
如何将字符串数组添加到JObject
?另外,为什么我会收到该错误?
试试这个方式:
JObject obj = new JObject();
obj.Add("item1", JToken.FromObject(new[] { "a", "b" }));