using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace skyscraper8.Json
{
	public class IpAddressJsonConverter : JsonConverter<IPAddress>
	{
		public override IPAddress? ReadJson(JsonReader reader, Type objectType, IPAddress? existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			string s = (string)reader.Value;
			return IPAddress.Parse(s);
		}

		public override void WriteJson(JsonWriter writer, IPAddress? value, JsonSerializer serializer)
		{
			writer.WriteValue(value.ToString());
		}
	}
}
