I am currently working on a C# project and I have encountered a scenario where I need to return a JSON object containing data from 2 different tables (Table and Table1).
My question is, how can I iterate through this data in order to copy it into 2 separate variables?
Ajax Call:-
$(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: '@Url.Action("DrawChart")',
data: '{}',
success: function (chartsdataSet) {
var chartsdata = chartsdataSet.Table[0];
}
});
JSON Object:-
{
"Table": [
{
"PlanName": "Half Yearly",
"Paymentamount": 17925,
"SettledAmount": 13300,
"PackageAmount": 12479
},
{
"PlanName": "Quaretly",
"Paymentamount": 7900,
"SettledAmount": 6000,
"PackageAmount": 8000
},
{
"PlanName": "Yearly",
"Paymentamount": 8200,
"SettledAmount": 9000,
"PackageAmount": 5198
}
],
"Table1": [
{
"year": 2017,
"monthid": 1,
"MonthName": "Jan",
"Paymentamount": 7900,
"SettledAmount": 6000,
"PackageAmount": 8000
},
{
"year": 2017,
"monthid": 2,
"MonthName": "Feb",
"Paymentamount": 1500,
"SettledAmount": 1300,
"PackageAmount": 1900
}
]
}