I am receiving bad JSON from server which is a string of actual array so I was using JSON.parse. I looked the asp code and I found that developers are converting list to JSON. What is the best way to encode list to JSON format?
Data that I am getting : {d:"[\\"[5970,5971,5972,5973,5976,5974,5975,5977,5978],[343,232]\\"]"}
Data should look like this : {d:[[5970,5971,5972,5973,5976,5974,5975,5977,5978],[343,232]]}
This is a tiny bit of JSON but it is 5MB of JSON so parsing takes lot of time.
I will really appreciated if someone can help me to find out solution for this as I am a UI guy. http://jsfiddle.net/aavUA/19
The asp code is which is actually calling c sharp function:
public static string GetLevelChildsList(string strInputString)
{
List<IndexReleationship> inflationRelationship = SessionManager.InflationRelation;
string[] inputArguments = strInputString.Split('~');
int intInflationModelLevelID = int.Parse(inputArguments[0].Trim());
List<string> lstResultString = new List<string>();
List<List<int>> strList = new List<List<int>>();
List<int> strInflationHideIdList = new List<int>();
List<int> strInflationShowIdList = new List<int>();
List<int> strActualLevelids = new List<int>();
List<int> selectedLevelids = new List<int>();
for (int count = 0; count < inflationRelationship.Count; count++)
{
if (inflationRelationship[count].IsReleatedIndex > intInflationModelLevelID)
{
if (!strInflationHideIdList.Contains(inflationRelationship[count].ParentIndexID))
{
strInflationHideIdList.Add(inflationRelationship[count].ParentIndexID);
}
if (!strInflationHideIdList.Contains(inflationRelationship[count].ChildIndexID))
{
strInflationHideIdList.Add(inflationRelationship[count].ChildIndexID);
}
}
else if (inflationRelationship[count].IsReleatedIndex == intInflationModelLevelID
&& inflationRelationship[count].IsReleatedIndex != 1169)
{
if (!strActualLevelids.Contains(inflationRelationship[count].ChildIndexID))
{
strActualLevelids.Add(inflationRelationship[count].ChildIndexID);
}
}
else
{
if (!strInflationShowIdList.Contains(inflationRelationship[count].ParentIndexID))
{
strInflationShowIdList.Add(inflationRelationship[count].ParentIndexID);
}
if (!strInflationShowIdList.Contains(inflationRelationship[count].ChildIndexID))
{
strInflationShowIdList.Add(inflationRelationship[count].ChildIndexID);
}
}
}
strList.Add(strInflationHideIdList);
strList.Add(strInflationShowIdList);
strList.Add(strActualLevelids);
selectedLevelids.AddRange(strInflationShowIdList);
selectedLevelids.AddRange(strActualLevelids);
string strResult = GetSessionInflationModels(selectedLevelids);
lstResultString.Add(strList.ToJson());
lstResultString.Add(strResult);
return lstResultString.ToJson();
}