summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Web
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 02:06:54 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 02:06:54 -0400
commit399b98b36b6111d364702b117fff3c5f21b8783a (patch)
tree211348da702363c67800be836bf726740c6f072b /src/StardewModdingAPI.Web
parent7d703c9c5ca76a99fc3d430fa2b3fd22301a5ffb (diff)
downloadSMAPI-399b98b36b6111d364702b117fff3c5f21b8783a.tar.gz
SMAPI-399b98b36b6111d364702b117fff3c5f21b8783a.tar.bz2
SMAPI-399b98b36b6111d364702b117fff3c5f21b8783a.zip
suppress null properties in JSON responses (#336)
Diffstat (limited to 'src/StardewModdingAPI.Web')
-rw-r--r--src/StardewModdingAPI.Web/Startup.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Web/Startup.cs b/src/StardewModdingAPI.Web/Startup.cs
index c1f03b34..2d9a95f1 100644
--- a/src/StardewModdingAPI.Web/Startup.cs
+++ b/src/StardewModdingAPI.Web/Startup.cs
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
using StardewModdingAPI.Web.Framework;
namespace StardewModdingAPI.Web
@@ -44,6 +45,11 @@ namespace StardewModdingAPI.Web
// add support for comma-delimited parameters
ArrayModelBinderProvider arrayModelBinderProvider = options.ModelBinderProviders.OfType<ArrayModelBinderProvider>().First();
options.ModelBinderProviders.Insert(options.ModelBinderProviders.IndexOf(arrayModelBinderProvider), new CommaDelimitedModelBinderProvider());
+ })
+ .AddJsonOptions(options =>
+ {
+ // suppress null values in JSON responses
+ options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
}