Mark Tabor

Mark Tabor

  • 587
  • 2k
  • 459.9k

JSON result is having larger size

Sep 12 2022 7:19 PM

Dear all below is my code although I have 2Lakh rows coming but the json size becomes 48MB , check the below code and let me know as when I run this code the visual studio get hangs

public JsonResult GetEmployeesLocation(string Country)
LocationAddress loc=new LocationAddress();
try
{
using(DBENTITY db=new DBENTITY())
{
List MyLoc=(from m in db.locations where m.country=="USA"
             select new LocationAddress
             {
            State=g.state,
            City=g.city,
            village=g.village,
            state_ID=(int)g.SID,
            City_ID=(int)C_ID,
            Village_ID=(int)V_ID,
             });
LocationAddress.location=MyLoc
return Json(LocationAddress,JsonRequestBehavior.AllowGet);
}
}

when I hit the api using postman it says "error during serliazitaion or deserialization using hte json javascriptseriealizer, the length of the string exceeds the value set on maxjsonlength.

I have increased the size it return the data but system hangs as it is 48MB of data


Answers (12)