Convert Newtonsoft.Json.Linq.JArray to a list of specific object type

前端 未结 6 1450
孤街浪徒
孤街浪徒 2020-11-28 18:43

I have the following variable of type {Newtonsoft.Json.Linq.JArray}.

properties[\"Value\"] {[
  {
    \"Name\": \"Username\",
    \"Selected\":         


        
6条回答
  •  独厮守ぢ
    2020-11-28 18:57

    Use IList to get the JArray Count and Use Loop to Convert into List

           var array = result["items"].Value();
    
            IList collection = (IList)array;
    
            var list = new List();
    
            for (int i = 0; i < collection.Count; j++)
                {
                  list.Add(collection[i].ToString());             
                }                         
    

提交回复
热议问题