0

I am using json.net for json object parsing. I have a string array that has of Json objects. so instead of 1 string with Json Array, I have each json object on different index of string array.

I need to de-serialize this string[] of json object into List<T>.

If it was string of Json Array to List<T> I would call JsonConvert.DeserializeObject<List<T>>(result);

But for this what would be the best approach to convert string[] of jsonobject into List<T>.

2 Answers 2

4

You can do that in a very simple way using Linq :

var list = jsonobjects.Select(JsonConvert.DeserializeObject<T>).ToList();
Sign up to request clarification or add additional context in comments.

Comments

2

You'll probably just have to call DeserializeObject on each string in the array.

var list = new List<T>();
foreach (var jsonString in result)
    list.Add(JsonConvert.DeserializeObject<T>(jsonString);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.