using System.Collections.Generic;
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations.Schema;
using SystemJsonIgnore = System.Text.Json.Serialization.JsonIgnoreAttribute;
using JsonSerializer = System.Text.Json.JsonSerializer;
public string Key { get; set;}
public object Value {get; set;}
public class DataValue<T>: DataValue {
public new T Value { get; set; }
public class StringDataValue : DataValue<string> {
public class IntDataValue : DataValue<int> {
public string Key { get; set; }
public class ModularNode : Node {
public IList<DataValue> Values { get; set; }
public static void Main()
DataValue dataValue = new StringDataValue {
DataValue dataValue2 = new IntDataValue {
Node modularNode = new ModularNode {
Values = new List<DataValue> {
var serialized = JsonSerializer.Serialize(modularNode, modularNode.GetType());
Console.WriteLine(serialized);
var serialized2 = JsonSerializer.Serialize(dataValue, dataValue.GetType());
Console.WriteLine(serialized2);
var serialized3 = JsonConvert.SerializeObject(modularNode);
Console.WriteLine(serialized3);