5

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"}]}

2 Answers 2

4

Try

return Json(new {answers = answers});
Sign up to request clarification or add additional context in comments.

Comments

2

It almost worked, the correct syntax is:

return Json(new { answers = answers});

Thx a lot =)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.