Skip to content

Latest commit

 

History

History
32 lines (29 loc) · 831 Bytes

CreateJsonCollectionInitializer.md

File metadata and controls

32 lines (29 loc) · 831 Bytes

Create JSON using Collection Initializers

This sample creates Argon.JObject and Argon.JArray instances using the C# collection initializer syntax.

var o = new JObject
{
    {"Cpu", "Intel"},
    {"Memory", 32},
    {
        "Drives", new JArray
        {
            "DVD",
            "SSD"
        }
    }
};

Console.WriteLine(o.ToString());
// {
//   "Cpu": "Intel",
//   "Memory": 32,
//   "Drives": [
//     "DVD",
//     "SSD"
//   ]
// }

snippet source | anchor