Skip to content

Commit bb83e32

Browse files
author
Bart Koelman
committed
Switched to STJ in rendering exception stack traces
1 parent 014aace commit bb83e32

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/JsonApiDotNetCore/Errors/JsonApiException.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text.Encodings.Web;
5+
using System.Text.Json;
6+
using System.Text.Json.Serialization;
47
using JetBrains.Annotations;
58
using JsonApiDotNetCore.Serialization.Objects;
6-
using Newtonsoft.Json;
79

810
namespace JsonApiDotNetCore.Errors
911
{
@@ -13,15 +15,16 @@ namespace JsonApiDotNetCore.Errors
1315
[PublicAPI]
1416
public class JsonApiException : Exception
1517
{
16-
private static readonly JsonSerializerSettings ErrorSerializerSettings = new()
18+
private static readonly JsonSerializerOptions SerializerOptions = new()
1719
{
18-
NullValueHandling = NullValueHandling.Ignore,
19-
Formatting = Formatting.Indented
20+
WriteIndented = true,
21+
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
22+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
2023
};
2124

2225
public IReadOnlyList<Error> Errors { get; }
2326

24-
public override string Message => $"Errors = {JsonConvert.SerializeObject(Errors, ErrorSerializerSettings)}";
27+
public override string Message => $"Errors = {JsonSerializer.Serialize(Errors, SerializerOptions)}";
2528

2629
public JsonApiException(Error error, Exception innerException = null)
2730
: base(null, innerException)

0 commit comments

Comments
 (0)