views:

280

answers:

2

i need to return a JSON with this format:

{"answers": [{"id": "93", "value":"Ahstron"}, 
             {"id"="94", "value"="Sampers"}]}

Im using the return Json() method form ASP MVC Framework, is there a way to specify that this JSOn is a collection of answers like in the sample code? or must i create my own?

with the

return Json(answers);

i just get this:

[{"id": "93", "value":"Ahstron"}, 
{"id"="94", "value"="Sampers"}]}
+3  A: 

Try

return Json(new {answers = answers});
James S
you should edit-fix the colon-error as stated below by Omar
Christian Dalager
+2  A: 

It almost worked, the correct syntax is:

return Json(new { answers = answers});

Thx a lot =)

Omar