I am first generating a dynamic object with: dynamic objetoTabla = new ExpandoObject();
, which I add the properties dynamically according to the data I generate with LINQ , until then everything is fine, then that created object I store it in a list type Object
. At the end I make a conversion:
var data = Newtonsoft.Json.JsonConvert.SerializeObject(Lista);
... and return:
return new JsonResult { Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
All that returns to me the following chain:
"[{\" Status \ ": \" 1.1 IN SERVICE \ ", \" BALESIA \ ": 22, \" Total \ ": 160, \" CT \ ": 81, \" TA \ ": 23, \ "TORRESEC \": 27, \ "TU \": 7}, {\ "Status \": \ "2.1 IN INSTALLATION \", \ "BALESIA \": 2, \ "Total \": 22, \ "CT \": 11, \ "TA \": 8, \ "TORRESEC \": 1, \ "TU \": 0}] "
Which is wrong, since it puts the quotes at the beginning of the array and the inverted bars inside the objects. What am I doing wrong? Is the object type converted to JSON in another way?
I need a JSON array, because that's what my angular table needs. I use dynamic because my angular table is dynamic, and it is armed according to the JSON properties.
I'm working on MVC4, C #.