This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not supporting [DataContract] See dotnet/corefx#33115
- Loading branch information
1 parent
a86e06b
commit 8caa3a3
Showing
4 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "2.2.105" | ||
"version": "3.0.100-preview6-012264" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
#if HAS_SYSTEM_JSON | ||
using System.Text.Json.Serialization; | ||
using Json = System.Text.Json.Serialization.JsonSerializer; | ||
#else | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
#endif | ||
|
||
namespace Sentry.Protocol.Tests | ||
{ | ||
internal class JsonSerializer | ||
{ | ||
#if HAS_SYSTEM_JSON | ||
|
||
private static readonly JsonSerializerOptions Options = new JsonSerializerOptions() | ||
{ | ||
IgnoreNullValues = true, | ||
}; | ||
|
||
public static string SerializeObject<T>(T @object) => Json.ToString(@object, Options); | ||
public static dynamic DeserializeObject(string json) => Json.Parse<dynamic>(json); | ||
#else | ||
private static readonly StringEnumConverter StringEnumConverter = new StringEnumConverter(); | ||
|
||
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | ||
{ | ||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor, | ||
NullValueHandling = NullValueHandling.Ignore, | ||
Formatting = Formatting.None, | ||
Converters = new[] { StringEnumConverter } | ||
Converters = new[] {StringEnumConverter} | ||
}; | ||
|
||
public static string SerializeObject<T>(T @object) => JsonConvert.SerializeObject(@object, Settings); | ||
public static dynamic DeserializeObject(string json) => JsonConvert.DeserializeObject(json); | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters