using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
public ActionResult Index17()
dynamic json = JsonConvert.DeserializeObject(@"{'doc':[ {
'billingDate': '2022-04-11T11:54:16.600Z',
'_id': '6256ce0404de4671d565cca6',
'createdDate': '2022-04-03T20:04:52.082Z',
'_id': '624a01981399dc7a14173dda',
'email': 'johndoe1@app.com',
'password': '3460c98eec954a700b17bbac9f14b222',
'providerName': 'Test Service',
'serviceProviderId': 'TES321326',
'_id': '6256ce0404de4671d565cca7',
'serviceName': 'husnain',
'_id': '6256ce0404de4671d565cca8',
'serviceName': 'husnain',
'_id': '6256ce0404de4671d565cca9',
'serviceName': 'husnain',
'createdDate': '2022-04-03T12:14:51.356Z',
'_id': '62498fc7acd7fb091185b88d',
'email': 'kpetherick3h@live.com',
'address': '1 Buhler Road',
'image': 'http://dummyimage.com/327x225.png/dddddd/000000',
'companyId': 'UDB21WROMBA8',
'password': '3460c98eec954a700b17bbac9f14b222',
'createdDate': '2022-04-03T17:09:47.994Z',
'_id': '6249d52bfef2560326a740e7',
'fName': 'James Bartley',
'motherName': 'Brunhilde',
'employeeImage': 'http://dummyimage.com/267x237.png/ff4444/ffffff',
'employeeID': 'YO550717',
'company': '62498fc7acd7fb091185b88d',
string name = json.doc[0].employee.fName;
string employeeId = json.doc[0].employee.employeeID;
int serviceCount = json.doc[0].services.Count;
var services = String.Empty;
for (int i = 0; i < serviceCount; i++)
services += "Service" + i.ToString() + Environment.NewLine;
services += "service id: " + json.doc[0].services[i]._id + Environment.NewLine;
services += "serviceName: " + json.doc[0].services[i].serviceName + Environment.NewLine;
services += "actualCost: " + json.doc[0].services[i].actualCost + Environment.NewLine;
services += "discountedCost: " + json.doc[0].services[i].discountedCost + Environment.NewLine;
services += Environment.NewLine;
Output output = new Output { Id = employeeId, Name = name, Services = services };
List<Output> list = new List<Output>();
var q = Json(list, JsonRequestBehavior.AllowGet);