Firstly thank you for taking the time to look at this. It's quite alot. Question: I'm basically trying to download a json as a string and then deserialize it to a list. The reason why is so i can then call a specific property of that list (in my case 'ips' because it's all i actually need) and insert it into a table if requirements are met. The problem is that it moves all null values into the array. 114 columns of null, or empty array and i can't figure out why? I think i'll attach a link to the JSON because its a massive file its here https://endpoints.office.com/endpoints/Worldwide?clientRequestId=b10c5ed1-bad1-445f-b386-b919946339a7
Here is my code:
- Getters and setters for JSON
public class GetSetJsonIP { [JsonProperty("id")] public int id { get; set; } [JsonProperty("serviceArea")] public string ServiceArea { get; set; } [JsonProperty("serviceAreaDisplayName")] public string ServiceAreaDisplayName { get; set; } [JsonProperty("urls")] public IList<string> urls { get; set; } [JsonProperty("ips")] public IList<string> ips { get; set; } [JsonProperty("tcpPorts")] public string tcpPorts { get; set; } [JsonProperty("expressRoute")] public bool expressRoute { get; set; } [JsonProperty("category")] public string category { get; set; } [JsonProperty("required")] public bool required { get; set; } [JsonProperty("notes")] public string notes { get; set; } [JsonProperty("udpPorts")] public string udpPorts { get; set; } } - List class
public class ConvertJsonIP{
public List<GetSetJsonIP> jsonIpConvert { get; set; }
public List<GetSetJsonIP> jsonIPConvert = new List<GetSetJsonIP>();
}
3.I download the JSON using an empty string called o365IP
o365IP = wc.DownloadString(wc.BaseAddress + "/endpoints/Worldwide?clientRequestId=b10c5ed1-bad1-445f-b386-b919946339a7");
- I deserialize using my List to a seperate var
var o365IpVerion = JsonConvert.DeserializeObject<List<ConvertJsonIP>>(o365IP);
This code shows no errors. so i can only assume its a logical one on my part. It should be noted that i had to put the <List< in to stop an error stating that it couldnt convert an object to an array.
Seriously, i've been stuck on this for 3 days so any help on this would be greatly appreciated! Thanks in advance!