Newtonsoft.Json.Linq.JArray to string array C#
90,795
If model.Users
is of type Newtonsoft.Json.Linq.JArray
try to call:
string[] Users = model.Users.ToObject<string[]>()
Related videos on Youtube
Author by
Fighter Plane
Updated on May 17, 2021Comments
-
Fighter Plane almost 3 years
I have a JSON Array like
model.Users = ["Joe","Barny","Power","Tester"]
the model is
dynamic
I want to convert
model.Users
tostring[] Users
string[] Users = model.Users
How can I do that?
-
Bernd Linde over 9 yearsHave you attempted anything? What is the definition of model.Users because it seems like it is a string[] already. The "JSON.Array" you supplied doesn't look like JSON, it looks more like an array declaration.
-
-
Jay over 3 yearsif you are adding a new answer to a very old question which already has so many answers, try and add a sentence explaining why and how this is better or different.
-
Trenton McKinney over 3 yearsThe provided answer was flagged for review as a Low Quality Post. Here are some guidelines for How do I write a good answer?. This provided answer could benefit from an explanation. Code only answers are not considered "good" answers. From Review.