public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddJsonOptions(options => { options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); }
這樣服務端返回的全部DateTime類型的Json數據中的日期都會被格式化成上述格式spa