Click or drag to resize
Json.NETSerialize Raw JSON value
 

This sample uses JRaw properties to serialize JSON with raw content.

Sample
Types
1public class JavaScriptSettings
2{
3    public JRaw OnLoadFunction { get; set; }
4    public JRaw OnUnloadFunction { get; set; }
5}
Usage
 1JavaScriptSettings settings = new JavaScriptSettings
 2{
 3    OnLoadFunction = new JRaw("OnLoad"),
 4    OnUnloadFunction = new JRaw("function(e) { alert(e); }")
 5};
 6
 7string json = JsonConvert.SerializeObject(settings, Formatting.Indented);
 8
 9Console.WriteLine(json);
10// {
11//   "OnLoadFunction": OnLoad,
12//   "OnUnloadFunction": function(e) { alert(e); }
13// }