Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 1.21 KB

File metadata and controls

35 lines (30 loc) · 1.21 KB

Serialize Raw JSON value

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

public class JavaScriptSettings
{
    public JRaw OnLoadFunction { get; set; }
    public JRaw OnUnloadFunction { get; set; }
}

snippet source | anchor

var settings = new JavaScriptSettings
{
    OnLoadFunction = [with("OnLoad")],
    OnUnloadFunction = [with("function(e) { alert(e); }")]
};

var json = JsonConvert.SerializeObject(settings, Formatting.Indented);

Console.WriteLine(json);
// {
//   "OnLoadFunction": OnLoad,
//   "OnUnloadFunction": function(e) { alert(e); }
// }

snippet source | anchor