Browse Source
Merge pull request #10746 from abpframework/maliming/SystemTextJson
Use the extension method of SystemTextJson.
pull/10760/head
liangshiwei
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
10 additions and
9 deletions
-
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpHasExtraPropertiesJsonConverter.cs
-
framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/SelectionStringValueItemSourceJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/StringValueTypeJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/ValueValidatorJsonConverter.cs
|
|
|
@ -27,12 +27,13 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters |
|
|
|
var rootElement = JsonDocument.ParseValue(ref reader).RootElement; |
|
|
|
if (rootElement.ValueKind == JsonValueKind.Object) |
|
|
|
{ |
|
|
|
var extensibleObject = JsonSerializer.Deserialize<T>(rootElement.GetRawText(), newOptions); |
|
|
|
var extensibleObject = rootElement.Deserialize<T>(newOptions); |
|
|
|
|
|
|
|
var extraPropertiesJsonProperty = rootElement.EnumerateObject().FirstOrDefault(x => x.Name.Equals(nameof(IHasExtraProperties.ExtraProperties), StringComparison.OrdinalIgnoreCase)); |
|
|
|
|
|
|
|
if (extraPropertiesJsonProperty.Value.ValueKind == JsonValueKind.Object) |
|
|
|
{ |
|
|
|
var extraPropertyDictionary = JsonSerializer.Deserialize(extraPropertiesJsonProperty.Value.GetRawText(), typeof(ExtraPropertyDictionary), newOptions); |
|
|
|
var extraPropertyDictionary = extraPropertiesJsonProperty.Value.Deserialize(typeof(ExtraPropertyDictionary), newOptions); |
|
|
|
ObjectHelper.TrySetProperty(extensibleObject, x => x.ExtraProperties, () => extraPropertyDictionary); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -13,12 +13,12 @@ namespace Volo.Abp.MemoryDb.JsonConverters |
|
|
|
var jsonDocument = JsonDocument.ParseValue(ref reader); |
|
|
|
if (jsonDocument.RootElement.ValueKind == JsonValueKind.Object) |
|
|
|
{ |
|
|
|
var entity = (TEntity)JsonSerializer.Deserialize(jsonDocument.RootElement.GetRawText(), typeToConvert); |
|
|
|
var entity = (TEntity)jsonDocument.RootElement.Deserialize(typeToConvert); |
|
|
|
|
|
|
|
var idJsonElement = jsonDocument.RootElement.GetProperty(nameof(Entity<object>.Id)); |
|
|
|
if (idJsonElement.ValueKind != JsonValueKind.Undefined) |
|
|
|
{ |
|
|
|
var id = JsonSerializer.Deserialize<TKey>(idJsonElement.GetRawText()); |
|
|
|
var id = idJsonElement.Deserialize<TKey>(); |
|
|
|
if (id != null) |
|
|
|
{ |
|
|
|
EntityHelper.TrySetId(entity, () => id); |
|
|
|
|
|
|
|
@ -19,7 +19,7 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
var newOptions = JsonSerializerOptionsHelper.Create(options, this); |
|
|
|
|
|
|
|
var selectionStringValueItem = |
|
|
|
JsonSerializer.Deserialize<LocalizableSelectionStringValueItem[]>(itemsJsonProperty.Value.GetRawText(), newOptions) ?? |
|
|
|
itemsJsonProperty.Value.Deserialize<LocalizableSelectionStringValueItem[]>(newOptions) ?? |
|
|
|
Array.Empty<LocalizableSelectionStringValueItem>(); |
|
|
|
|
|
|
|
return new StaticSelectionStringValueItemSource(selectionStringValueItem.As<ISelectionStringValueItem[]>()); |
|
|
|
|
|
|
|
@ -22,9 +22,9 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
|
|
|
|
return name switch |
|
|
|
{ |
|
|
|
"SelectionStringValueType" => JsonSerializer.Deserialize<SelectionStringValueType>(rootElement.GetRawText(), newOptions), |
|
|
|
"FreeTextStringValueType" => JsonSerializer.Deserialize<FreeTextStringValueType>(rootElement.GetRawText(), newOptions), |
|
|
|
"ToggleStringValueType" => JsonSerializer.Deserialize<ToggleStringValueType>(rootElement.GetRawText(), newOptions), |
|
|
|
"SelectionStringValueType" => rootElement.Deserialize<SelectionStringValueType>(newOptions), |
|
|
|
"FreeTextStringValueType" => rootElement.Deserialize<FreeTextStringValueType>(newOptions), |
|
|
|
"ToggleStringValueType" => rootElement.Deserialize<ToggleStringValueType>(newOptions), |
|
|
|
_ => throw new ArgumentException($"{nameof(IStringValueType)} named {name} was not found!") |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
@ -23,7 +23,7 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
if (propertiesJsonProperty.Value.ValueKind == JsonValueKind.Object) |
|
|
|
{ |
|
|
|
var newOptions = JsonSerializerOptionsHelper.Create(options, this, new ObjectToInferredTypesConverter()); |
|
|
|
var properties = JsonSerializer.Deserialize<IDictionary<string, object>>(propertiesJsonProperty.Value.GetRawText(), newOptions); |
|
|
|
var properties = propertiesJsonProperty.Value.Deserialize<IDictionary<string, object>>(newOptions); |
|
|
|
if (properties != null && properties.Any()) |
|
|
|
{ |
|
|
|
foreach (var property in properties) |
|
|
|
|