0

I am using razor in webmatrix. I have a dictionary object

var occupancyTotalDic = new Dictionary<double, int>();

Once I have filled the dictionary with data I wish to output as JSON as a response to populate a flot chart

Dictionary<String, String> input = new Dictionary<String, String>();
occupancyTotalDic = input.ToDictionary(item => item.Key, item => (String)item.Value);

Response.ContentType = "application/json";
Response.Write(Json.Encode(occupancyTotalDic));

How do I convert my dictionary to contain strings so that I can output as JSON?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1222646
  • 123
  • 1
  • 2
  • 9

1 Answers1

0

Since Webmatrix can't compile MVC application I assume you are using ASP.NET webforms.

Tried this solution https://stackoverflow.com/a/5597628/713789

If you are using MVC then just use JsonResult test(){ return Json(myobj);}

Community
  • 1
  • 1
Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79