using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public WorkSheet(string name, int? captionln)
captionLineNumber = captionln;
[JsonProperty("caption_ln")]
private int _defaultCaptionLineNum;
[JsonProperty("defaultCaptionLineNum")]
public int DefaultCaptionLineNum { get { return _defaultCaptionLineNum; } }
private Dictionary<int, WorkSheet> _worksheets = new Dictionary<int, WorkSheet>();
[JsonProperty("worksheets")]
public Dictionary<int, WorkSheet> Worksheets { get { return _worksheets; } set { _worksheets = value; } }
Console.WriteLine("New MyClass object created!");
public static void Test()
var root = JsonConvert.DeserializeObject<MyClass>(json);
var json2 = JsonConvert.SerializeObject(root, Formatting.Indented);
Console.WriteLine(json2);
""defaultCaptionLineNum"": 6,
""0"": { ""name"": ""Ws1"", ""caption_ln"": 6 },
""1"": { ""name"": ""Ws2"", ""caption_ln"": null },
""2"": { ""name"": ""Ws3"" },
""3"": { ""name"": ""Ws4"", ""caption_ln"": 5 },
public static void Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("Json.NET version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public class AssertionFailedException : System.Exception
public AssertionFailedException() : base() { }
public AssertionFailedException(string s) : base(s) { }
public static class Assert
public static void IsTrue(bool value)
public static void IsTrue(bool value, string message)
throw new AssertionFailedException(message ?? "failed");