简体   繁体   中英

How to Deserialise Array into List without using Foreach?

I deserialized array into List using for each. But its taking too much time to deserialize when no of records more than 1000. This is my code :

 // Access record from API
 string response = await httpClient.GetStringAsync(new Uri(url)); 

 // Decode...                
 var myArray = JArray.Parse(response);

// Deserialize... 

foreach (JObject jo in myArray)
{                   

   var myObject= JsonConvert.DeserializeObject<myObject>(jo.ToString());

       myObjectList.Add (myObject);

}

So my question is how to deserialize Array without using for each ?? OR Is there any better way to increase performance?

Thank you

你有没有尝试过

JsonConvert.DeserializeObject<List<MyObject>>(response);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM