public static void Main(string[] args) { Console.WriteLine("Serialized output: "); Console.WriteLine(Json2.Stringify(new MainClass())); Console.WriteLine("Deserialized output: "); dynamic json = Json2.Parse("{ \"test\": [1,2,3,4,5], \"obj\": { \"inobj\": \"Im inside an object\" } }"); Console.WriteLine("Array Contents: "); foreach (string val in json.test) { Console.WriteLine(val); } Console.WriteLine(); Console.WriteLine("Object property value: "); Console.WriteLine(json.obj.inobj); }
private string GetDifference(object doc1, object doc2) { Json1 = doc1.ToJson(true); Json2 = doc2.ToJson(true); var jsLines1 = Json1.SplitByLine(); var jsLines2 = Json2.SplitByLine(); var maxLines = Math.Max(jsLines1.Length, jsLines2.Length); var diffs = new List <string>(); for (int i = 0; i < maxLines; i++) { var line1 = jsLines1.ElementAtOrDefault(i); var line2 = jsLines2.ElementAtOrDefault(i); if (line1 != line2) { diffs.Add($"[{line1}]" + " - vs - " + $"[{line2}]"); } } return(diffs.Any() ? string.Join(L.f, diffs) : null); }
public void JsonInput2(Json2 json) { }
public void JsonInput2(Json2 json) { }