using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
public static void Main(string[] args)
DisplayTitle = "Black Dog",
DisplayName = "Led Zeppelin",
Created = DateTime.Today,
Updated = DateTime.Today,
string json = JsonConvert.SerializeObject(track, Formatting.Indented);
private Guid Id { get; set; }
public string Name { get; set; }
public string DisplayName { get; set; }
public bool IsGroup { get; set; }
public bool IsActive { get; set; }
public string Country { get; set; }
public class Artist : ArtistInfo
public DateTime Created { get; set; }
public int CreatedById { get; set; }
public DateTime Updated { get; set; }
public int UpdatedById { get; set; }
public string Title { get; set; }
public string DisplayTitle { get; set; }
public int Year { get; set; }
public int Duration { get; set; }
public int? TrackNumber { get; set; }
public ArtistInfo Artist { get; set; }
public class BaseTypeConverter<T> : JsonConverter
public override bool CanConvert(Type objectType)
return typeof(T).IsAssignableFrom(objectType);
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
JObject obj = new JObject();
foreach (PropertyInfo prop in typeof(T).GetProperties())
obj.Add(prop.Name, JToken.FromObject(prop.GetValue(value)));
public override bool CanRead
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
throw new NotImplementedException();