diff --git a/JWT.sln.DotSettings b/JWT.sln.DotSettings
index a015806f3..288827a8e 100644
--- a/JWT.sln.DotSettings
+++ b/JWT.sln.DotSettings
@@ -1,4 +1,8 @@
HMACSHA
RS
+ True
+ JWT.sln.DotSettings
+ True
+ 1
\ No newline at end of file
diff --git a/src/JWT/JWT.csproj b/src/JWT/JWT.csproj
index e82e617c8..d9e491655 100644
--- a/src/JWT/JWT.csproj
+++ b/src/JWT/JWT.csproj
@@ -21,7 +21,7 @@
https://github.com/jwt-dotnet/jwt
John Sheehan, Michael Lehenbauer, Alexander Batishchev
https://creativecommons.org/publicdomain/zero/1.0/
- 3.0.0-beta4
+ 3.0.0
jwt json
diff --git a/src/JWT/Serializers/JsonNetSerializer.cs b/src/JWT/Serializers/JsonNetSerializer.cs
index 20a34360a..f305f31b9 100644
--- a/src/JWT/Serializers/JsonNetSerializer.cs
+++ b/src/JWT/Serializers/JsonNetSerializer.cs
@@ -1,4 +1,6 @@
-using Newtonsoft.Json;
+using System;
+using System.Linq;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JWT.Serializers
@@ -8,25 +10,37 @@ namespace JWT.Serializers
///
public sealed class JsonNetSerializer : IJsonSerializer
{
+ private readonly JsonSerializer _serializer;
+
///
- /// Serialize the given object.
+ /// Creates a new instance of .
///
- /// The object to serialize.
- ///
- public string Serialize(object obj)
+ /// Uses as internal serializer.
+ public JsonNetSerializer()
+ : this(JsonSerializer.CreateDefault())
{
- return JObject.FromObject(obj).ToString(Formatting.None);
+
}
///
- /// Deserialize the given string.
+ /// Creates a new instance of .
///
- /// The type to deserialize the string to.
- /// The JSON to be deserialized.
- ///
+ /// Internal to use for serialization.
+ public JsonNetSerializer(JsonSerializer serializer)
+ {
+ _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
+ }
+
+ ///
+ public string Serialize(object obj)
+ {
+ return JObject.FromObject(obj, _serializer).ToString(_serializer.Formatting, _serializer.Converters.ToArray());
+ }
+
+ ///
public T Deserialize(string json)
{
- return JObject.Parse(json).ToObject();
+ return JObject.Parse(json).ToObject(_serializer);
}
}
}
\ No newline at end of file
diff --git a/tests/JWT.Tests.Common/JwtDecoderTest.cs b/tests/JWT.Tests.Common/JwtDecoderTest.cs
index 5ca36046c..25a455c34 100644
--- a/tests/JWT.Tests.Common/JwtDecoderTest.cs
+++ b/tests/JWT.Tests.Common/JwtDecoderTest.cs
@@ -2,8 +2,8 @@
using FluentAssertions;
using JWT.Algorithms;
using JWT.Serializers;
-using Xunit;
using JWT.Tests.Common;
+using Xunit;
namespace JWT.Tests
{
diff --git a/tests/JWT.Tests.Common/JwtEncoderTest.cs b/tests/JWT.Tests.Common/JwtEncoderTest.cs
index c2b88044a..280ecba37 100644
--- a/tests/JWT.Tests.Common/JwtEncoderTest.cs
+++ b/tests/JWT.Tests.Common/JwtEncoderTest.cs
@@ -2,8 +2,8 @@
using FluentAssertions;
using JWT.Algorithms;
using JWT.Serializers;
-using Xunit;
using JWT.Tests.Common;
+using Xunit;
namespace JWT.Tests
{