JSON.NET converters including: MillisecondTimeSpanJsonConverter
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Code
Tests
.gitignore
LICENSE
README.md
Zoltu.JsonNet.Converters.sln
Zoltu.JsonNet.Converters.v2.ncrunchsolution
appveyor.yml

README.md

Zoltu.JsonNet.Converters

JSON.NET converters including: MillisecondTimeSpanJsonConverter

Usage

[Fact]
public void serialize_timespan_as_milliseconds()
{
	const String expected = @"5000";
	var inputTimeSpan = TimeSpan.FromMilliseconds(5000);

	var actual = JsonConvert.SerializeObject(inputTimeSpan, new MillisecondTimeSpanJsonConverter());

	Assert.Equal(expected, actual);
}

[Fact]
public void deserialize_timespan_as_milliseconds()
{
	var expected = TimeSpan.FromMilliseconds(5000);
	const String inputJson = @"5000";

	var actual = JsonConvert.DeserializeObject<TimeSpan>(inputJson, new MillisecondTimeSpanJsonConverter());

	Assert.Equal(expected, actual);
}