Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 1.2 KB

SerializeRawJson.md

File metadata and controls

35 lines (30 loc) · 1.2 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 = new("OnLoad"),
    OnUnloadFunction = new("function(e) { alert(e); }")
};

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

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

snippet source | anchor