I use this method to generate JSON from the list:
last code
but return JSON has errors like:
expecting object or array, not string
Multiple JSON root elements
you see JSON file in this link and test it in this site:
edit:
I change my code with this:
[HttpPost]
    [Route("api/Users/GetAllGoodInCat")]
    public object GetAllGoodInCat([FromBody]GoodsCatId goodsCatId)
    {
        try
        {
            if (goodsCatId.id != 0)
            {
                var getCat = (from a in db.goodsGroups
                                 where a.Id == goodsCatId.id
                                 select a).SingleOrDefault();
                if (getCat != null)
                {
                    var getAllfood = from a in db.goods
                        where a.groupId == goodsCatId.id
                        orderby a.Id
                        select a;
                    var resultList = new List<string>();
                    foreach (var good in getAllfood)
                    {
                        var obj = new SearchGoods()
                        {
                            good = new MyGoods
                            {
                                id = good.Id,
                                name = good.name,
                                price = good.price,
                                brand = new MyGoodsBrand
                                {
                                    id = getCat.Id,
                                    name = getCat.title,
                                    image = getCat.image
                                }
                            }
                        };
                        resultList.Add(new JavaScriptSerializer().Serialize(obj));
                    }
                    return resultList;
                }                   
            }
            return message.ProgramError();
        }
        catch (Exception)
        {
            return message.ProgramError();
        }
    }
    private class AllCat
    {
        public int id;
        public string name;
        public string image;
        public SubLevelOne subLevelOne;
    }
    private class SubLevelOne
    {
        public int id;
        public string name;
        public string image;
        public SubLevelTwo subLevelTwo;
    }
    private class SubLevelTwo
    {
        public int id;
        public string name;
        public string image;
    }
Now my json is like this link:
[
   "{\"good\":{\"id\":1,\"name\":\"برنج دانه بلند محسن\",\"price\":20000,\"brand\":{\"id\":22,\"name\":\"برنج محسن\",\"image\":\"testmy.png\"}}}",
   "{\"good\":{\"id\":2,\"name\":\"برنج عطری\",\"price\":30000,\"brand\":{\"id\":22,\"name\":\"برنج محسن\",\"image\":\"testmy.png\"}}}",
   "{\"good\":{\"id\":3,\"name\":\"برنج سر سیاه\",\"price\":15000,\"brand\":{\"id\":22,\"name\":\"برنج محسن\",\"image\":\"testmy.png\"}}}"
]
but I want sth like this
also waht is ( \ ) is json file?
 
     
     
    