11,578 questions
JSON Deserialization not parsing all properties JIRA API 3
SSinhg
316
Reputation points
I am parsing a JSON response from Jira API 3 for Change Log
I generated the response classes using json2csharp.com here's how it looks
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class AvatarUrls
{
public string _48x48 { get; set; }
public string _24x24 { get; set; }
public string _16x16 { get; set; }
public string _32x32 { get; set; }
}
public class Author
{
public string self { get; set; }
public string accountId { get; set; }
public string emailAddress { get; set; }
public AvatarUrls avatarUrls { get; set; }
public string displayName { get; set; }
public bool active { get; set; }
public string timeZone { get; set; }
}
public class Item
{
public string field { get; set; }
public string fieldtype { get; set; }
public string fieldId { get; set; }
public string from { get; set; }
public string fromString { get; set; }
public string to { get; set; }
public string toString { get; set; }
}
public class Value
{
public string id { get; set; }
public Author author { get; set; }
public DateTime created { get; set; }
public List<Item> items { get; set; }
}
public class JsonResponseChangeLog
{
public string self { get; set; }
public string nextPage { get; set; }
public int maxResults { get; set; }
public int startAt { get; set; }
public int total { get; set; }
public bool isLast { get; set; }
public List<Value> values { get; set; }
}
My c# code for parsing JSON response
..... HTTPClient & HttpRequestMessage objects
var base64authorization = Convert.ToBase64String(Encoding.ASCII.GetBytes("" + userName + ":"+ apiToken));
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64authorization}");
var response = httpClient.SendAsync(request).Result;
string responseString = null;
if (response.IsSuccessStatusCode)
{
var responseContent = response.Content.ReadAsStringAsync().Result;
var myDeserializedClass =
JsonConvert.DeserializeObject<JsonResponseChangeLog>(responseContent);
}
My result under value is always null
Developer technologies | C#
Sign in to answer