How to remove first and last square brackets from JSON from query string web api c#

asp.net-web-api2 c# entity-framework-6 json

Question

how to get rid of the responseSQUARE BRACKET FROM result - Reaction[]

public HttpResponseMessage GetDetail(int id)
    {

        var result = new Dictionary<string, object>();
        EDetail EDetailobj = db.EDetails.FirstOrDefault(P => P.DetailID == id);
        if (EDetailobj != null)
        {
            result.Add("Status", "ok");

            var responseResult = db.EDetails
                .Where(x => x.DetailID == id)
                .Select(x => new
                {
                    x.DetailID ,
                    x.DetailName,
                    x.Qty,
                    x.Price,
                });
            result.Add("Response", responseResult);
            return Request.CreateResponse(HttpStatusCode.OK, result);
        }
        else
        {
            result.Add("Status", "failure");
            return Request.CreateResponse(result);
        }
    }

{
  "status": "ok",
  "response": [
    {
      "detailID": 1,
      "detailName": "whiteshirt",
      "qty": 12,
      "price": 21.0,
    }
  ]
}
1
0
2/1/2018 10:05:50 PM

Popular Answer

ZZZ_tmp
2
2/1/2018 11:30:26 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow