0

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:[{...........}]

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

Comments

0

Try to Convert it in your ajax, like this:

 var ResponseData= JSON.Signfy(data);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.