ABP vNext
安装Microsoft.AspNetCore.Mvc.NewtonsoftJson
private void ConfigureJson(ServiceConfigurationContext context)
{
context.Services.AddControllers().AddNewtonsoftJson(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();//属性名大写
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;//防递归
options.SerializerSettings.Converters.Add(new StringEnumConverter());//枚举返回字符串
options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;//格式化json
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;//null字段不显示
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";//日期格式化
});
}
ApplicationService统一返回JsonResult
RestSharp
安装RestSharp.Serializers.NewtonsoftJson
var client = new RestClient($"url");
client.UseNewtonsoftJson();