Browse Source

Don't use custom JsonSerializerOptions instances in OpenIddictParameter

pull/1418/head
Kévin Chalet 5 years ago
parent
commit
f09329af41
  1. 19
      src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs

19
src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs

@ -7,7 +7,6 @@
using System.Collections.Immutable; using System.Collections.Immutable;
using System.ComponentModel; using System.ComponentModel;
using System.Globalization; using System.Globalization;
using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
#if SUPPORTS_JSON_NODES #if SUPPORTS_JSON_NODES
@ -605,11 +604,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
JsonValue value when value.TryGetValue(out string? result) => result, JsonValue value when value.TryGetValue(out string? result) => result,
JsonNode value => value.ToJsonString(new JsonSerializerOptions JsonNode value => value.ToJsonString(),
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = false
}),
#endif #endif
_ => string.Empty _ => string.Empty
}; };
@ -734,11 +729,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
#if SUPPORTS_JSON_NODES #if SUPPORTS_JSON_NODES
case JsonNode value: case JsonNode value:
value.WriteTo(writer, new JsonSerializerOptions value.WriteTo(writer);
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = false
});
break; break;
#endif #endif
} }
@ -851,11 +842,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
// Otherwise, serialize it to get a JsonElement instance. // Otherwise, serialize it to get a JsonElement instance.
#if SUPPORTS_DIRECT_JSON_ELEMENT_SERIALIZATION #if SUPPORTS_DIRECT_JSON_ELEMENT_SERIALIZATION
object value => JsonSerializer.SerializeToElement(value, value.GetType(), new JsonSerializerOptions object value => JsonSerializer.SerializeToElement(value, value.GetType())
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
WriteIndented = false
})
#else #else
object value => DeserializeElement(JsonSerializer.Serialize(value)) ?? default object value => DeserializeElement(JsonSerializer.Serialize(value)) ?? default
#endif #endif

Loading…
Cancel
Save