This method:
public int? getTotal() {
if (response != null) {
Dictionary<string, object> responseData = (Dictionary<string, object>) response["response"];
total = (int?)responseData["total"];
}
return total;
}
throws an exception because the cast is invalid.
Suggested fix:
public int? getTotal() {
if (response != null) {
Dictionary<string, object> responseData = (Dictionary<string, object>) response["response"];
var t = (JsonElement)responseData["total"];
if (t.ValueKind == JsonValueKind.Number) return t.GetInt32();
}
return null;
}
This method:
public int? getTotal() {
if (response != null) {
Dictionary<string, object> responseData = (Dictionary<string, object>) response["response"];
total = (int?)responseData["total"];
}
return total;
}
throws an exception because the cast is invalid.
Suggested fix:
public int? getTotal() {
if (response != null) {
Dictionary<string, object> responseData = (Dictionary<string, object>) response["response"];
var t = (JsonElement)responseData["total"];
if (t.ValueKind == JsonValueKind.Number) return t.GetInt32();
}
return null;
}