I tried
JObject obj = new JObject();
obj["item1"] = new string[] {"a","b"};
and got
Cannot implicitly convert type 'string[]' to 'Newtonsoft.Json.Linq.JToken'
How do I add a string array to a JObject
? Also, why do I get that error?
Try this way:
JObject obj = new JObject();
obj.Add("item1", JToken.FromObject(new[] { "a", "b" }));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With