Set NumberHandling of JsonSerializerOptions to JsonNumberHandling.Strict.

pull/9700/head
maliming 4 years ago
parent f1106699e7
commit 76317521fb

@ -6,12 +6,12 @@ $rootFolder = (Get-Item -Path "./" -Verbose).FullName
# List of solutions used only in development mode # List of solutions used only in development mode
$solutionPaths = @( $solutionPaths = @(
# "../framework", "../framework",
"../modules/basic-theme", "../modules/basic-theme",
"../modules/users", "../modules/users",
"../modules/permission-management", "../modules/permission-management",
"../modules/setting-management", "../modules/setting-management",
# "../modules/feature-management", "../modules/feature-management",
"../modules/identity", "../modules/identity",
"../modules/identityserver", "../modules/identityserver",
"../modules/tenant-management", "../modules/tenant-management",

@ -30,6 +30,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Json
options.JsonSerializerOptions.Converters.Add(new ObjectToInferredTypesConverter()); options.JsonSerializerOptions.Converters.Add(new ObjectToInferredTypesConverter());
options.JsonSerializerOptions.Converters.Add(new AbpHasExtraPropertiesJsonConverterFactory()); options.JsonSerializerOptions.Converters.Add(new AbpHasExtraPropertiesJsonConverterFactory());
// Remove after this PR.
// https://github.com/dotnet/runtime/pull/51739
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.Strict;
} }
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.Json.SystemTextJson.JsonConverters; using Volo.Abp.Json.SystemTextJson.JsonConverters;
@ -49,6 +50,11 @@ namespace Volo.Abp.EntityFrameworkCore.ValueConverters
var deserializeOptions = new JsonSerializerOptions(); var deserializeOptions = new JsonSerializerOptions();
deserializeOptions.Converters.Add(new ObjectToInferredTypesConverter()); deserializeOptions.Converters.Add(new ObjectToInferredTypesConverter());
// Remove after this PR.
// https://github.com/dotnet/runtime/pull/51739
deserializeOptions.NumberHandling = JsonNumberHandling.Strict;
var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, deserializeOptions) ?? var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, deserializeOptions) ??
new ExtraPropertyDictionary(); new ExtraPropertyDictionary();

@ -1,5 +1,6 @@
using System; using System;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json.Serialization;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.Json.SystemTextJson.JsonConverters; using Volo.Abp.Json.SystemTextJson.JsonConverters;
@ -28,6 +29,10 @@ namespace Volo.Abp.Json.SystemTextJson
// If the user hasn't explicitly configured the encoder, use the less strict encoder that does not encode all non-ASCII characters. // If the user hasn't explicitly configured the encoder, use the less strict encoder that does not encode all non-ASCII characters.
options.JsonSerializerOptions.Encoder ??= JavaScriptEncoder.UnsafeRelaxedJsonEscaping; options.JsonSerializerOptions.Encoder ??= JavaScriptEncoder.UnsafeRelaxedJsonEscaping;
// Remove after this PR.
// https://github.com/dotnet/runtime/pull/51739
options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.Strict;
} }
} }
} }

Loading…
Cancel
Save