using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Text.Json.Serialization;
public string title { get; set; }
public string name { get; set; }
public int width { get; set; }
public int height { get; set; }
public string src { get; set; }
public string name { get; set; }
public int hOffset { get; set; }
public int vOffset { get; set; }
public string alignment { get; set; }
public string data { get; set; }
public int size { get; set; }
public string style { get; set; }
public string name { get; set; }
public int hOffset { get; set; }
public int vOffset { get; set; }
public string alignment { get; set; }
public string onMouseUp { get; set; }
public string debug { get; set; }
public Window window { get; set; }
public Image image { get; set; }
public Text text { get; set; }
public Widget widget { get; set; }
public static void Test()
var root = JsonSerializer.Deserialize<Root>(json);
""title"": ""Sample Konfabulator Widget"",
""name"": ""main_window"",
""width"": ""500"", // ERROR ADDED HERE
""src"": ""Images/Sun.png"",
""alignment"": ""center""
""data"": ""Click Here"",
""alignment"": ""center"",
""onMouseUp"": ""sun1.opacity = (sun1.opacity / 100) * 90;""
public static void Main()
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("System.Text.Json version: " + typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.CodeBase.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];