I'm trying to convert my view model data to JSON, however, I can't seem to access @Json.Encode
. I've added the System.Web.Helpers
reference, but that didn't work. What am I doing wrong?
Asked
Active
Viewed 5,568 times
4

Zabavsky
- 13,340
- 8
- 54
- 79

CinnamonBun
- 1,150
- 14
- 28
-
See this article at SO: http://stackoverflow.com/questions/12682128/mvc-4-assembly-reference-missing-for-json-encode – Patrick Hofman Jan 19 '14 at 13:13
1 Answers
9
Put this at the top of your view
@using Newtonsoft.Json
And then you can do this
@Html.Raw(@JsonConvert.SerializeObject(ViewBag.MyStuff))

Greg Ennis
- 14,917
- 2
- 69
- 74