Click here to Skip to main content
15,895,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am generate a JSON with
C#
public JsonResult GetLawcategory()
        {
            
            List<lawcategory> _ListLawCategory = new List<lawcategory>();
            ArrayList aData = new ArrayList();
            var v = db.sp_GET_LAWCATEGORY();
            string strDesign = string.Empty;
            if (v != null)
            {
                foreach (var result in v)
                {
                    
                    LawCategory _LawCategory = new LawCategory();
                    _LawCategory.LawCategoryID = result.LawCategoryID;
                    _LawCategory.LawCategoryName = result.LawCategoryName;
                    _LawCategory.ParentCategory = result.ParentCategory;
                    _LawCategory.Status = result.Status;
                    _LawCategory.CountryName = result.CountryName;
                    //_ListLawCategory.Add(_LawCategory);
                    aData.Insert(aData.Count, _LawCategory);
                   

                }


            }
          
            return Json(aData, JsonRequestBehavior.AllowGet);

        }

This Code and and found in fire bug this genarate json like
http://www.countryonwheels.com/2.png[^]

but i want my JSON like http://www.countryonwheels.com/1.png[^]

How can i can do this please help me .
Thankx
Posted
Updated 10-Aug-13 10:31am
v2

1 solution

Well, it is working at it should work - and in general it should not present any difficulty to use what you get.
You have two options:
1) Don't add objects to the list, add array of string.
2) Use a more advanced json encoder (fastjson, json.net,...), that allows you to shape the result
But I suggest simply take option 1.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900