I have a json response which is returning me a list of image's URLs and all the URLs are separated by comma(","). I split the response by using split
function to separate all the URLs from each other and then I add all the URLs in my list.
But whenever I want to access that list (in the same class) after adding URLs into it, I get nothing. I checked the count of the list and it's 0. Here is the code:
//initialization of list
List<string> productGallery = new List<string>();
//Parsing the json response
var jArray = JArray.Parse(data);
var gallery = jArray[0]["gallery"].Value<string>();
var splitted = gallery.Split(",");
for (int i = 0; i < splitted.Length; i++)
{
//adding into list
productGallery.Add(splitted[i]);
}
Here is the Json response before I am applying Parse method on it
Json response:[
{
"id": "2",
"gallery": "https://sakany.ma//images/sakany-logo.png,https://sakany.ma/images/sub_services/leak-sink.jpg,https://sakany.ma/images/sub_services/shower_head.jpg"
}
]