Reputation: 197
I am using mvc5. Please help me to get data from JSON array. This is my Controller
public ActionResult Index()
{
var data = ObjRepo.GetEmployees(1);
ObjHybrid.data = data;
// return View(ObjHybrid);
return Json(new {data=ObjHybrid},behavior:JsonRequestBehavior.AllowGet);
}
Right now I am getting data as
{"data":{"data":[{"Emp_Id":101,"EmpName":"Hussain","Email":"[email protected]","Psw":null,"Cnt_Id":0,"Cnt_Name":"India"}]
But I need as
"Data:[{...........}]
Upvotes: 0
Views: 105
Reputation: 191
Try to Convert it in your ajax, like this:
var ResponseData= JSON.Signfy(data);
Upvotes: 0
Reputation: 218892
Currently you are passing an anonymous object with a data
property and it's value is your ObjHybrid
object.
Looks like you want ObjHybrid
object as the response json data. In that case, do not use the anonymous object. Just Pass the ObjHybrid
object as the first parameter(data) of the Json
method
return Json(ObjHybrid,JsonRequestBehavior.AllowGet);
Upvotes: 1