using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
Model model = JsonConvert.DeserializeObject<Model>(json);
Console.WriteLine(string.Join(", ", model.Standards));
json = JsonConvert.SerializeObject(model, Formatting.Indented);
[JsonConverter(typeof(CustomHashSetConverter))]
public HashSet<string> Standards { get; set; }
public class CustomHashSetConverter : JsonConverter
public override bool CanConvert(Type objectType)
return objectType == typeof(HashSet<string>);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
JObject jo = JObject.Load(reader);
return new HashSet<string>(jo.Properties().Select(p => p.Name));
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
HashSet<string> hashSet = (HashSet<string>)value;
JArray ja = new JArray(hashSet);