I'm trying to return a dynamic json array to the client side in mvc.
So far I have
var a = 1;
var b = 10;
var jsonArray = new JArray();
for (var i = 1; i < 5; i++)
{
var json = new JObject();
json.Add("field" + a, b);
jsonArray.Add(json);
a++;
b++;
}
return Json(jsonArray);
this returns to the client
[[[[]]]]
I have tried converting the JsonArray to a string first and setting it to have no formatter, but that doesn't return valid json according to fiddler.
I'd expect the result to be soemething like:
[{field1:10},{field2:11},{field3:12}]
Can anyone point out what I'm doing wrong