I am trying to create the json needed to create an object in jQuery using C#. The json needed is
{
title: 'title text',
upperVal: 40,
lowerVal: 5,
mouseover: function() { return 'difference ' + (upperVal - lowerVal); }
}
The first few elements were simple enough. I created a class to represent the object, JSObj, and then run this through JavascriptSerializer.Serialize()
public class JSObj {
public string title { get; set; }
public int upperVal { get; set; }
public int lowerVal { get; set; }
}
This works fine for the first few attributes, but I don't have a clue how to return the correct mouseover function.
EDIT: The code provided is just sample code because the structure of the json I'm actually using is a bit more complicated. I'm using HighCharts, and one of the config options that I really need to use requires a function, even though they are not really valid json ( http://www.highcharts.com/ref/#tooltip--formatter ) so unfortunately I can't avoid the problem