From 7c6607a000b6239e86d1736a1815264af55c13e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Steffen=20Kie=C3=9F?= Date: Tue, 19 Sep 2017 20:41:16 +0200 Subject: [PATCH] Allow passing null to JsonArray.Add() null is a valid value in a JSON array, so there is no reason forbid adding null to the array. JsonArray.Save() already handles null values in the array. --- mcs/class/System.Json/System.Json/JsonArray.cs | 3 --- mcs/class/System.Json/Test/System.Json/JsonValueTest.cs | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mcs/class/System.Json/System.Json/JsonArray.cs b/mcs/class/System.Json/System.Json/JsonArray.cs index c63004422b5..524e3e8b750 100644 --- a/mcs/class/System.Json/System.Json/JsonArray.cs +++ b/mcs/class/System.Json/System.Json/JsonArray.cs @@ -45,9 +45,6 @@ namespace System.Json public void Add (JsonValue item) { - if (item == null) - throw new ArgumentNullException ("item"); - list.Add (item); } diff --git a/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs b/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs index b267bd7c98e..baff3cc32b1 100644 --- a/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs +++ b/mcs/class/System.Json/Test/System.Json/JsonValueTest.cs @@ -44,6 +44,9 @@ namespace MonoTests.System Assert.AreEqual (JsonType.Array, j.JsonType, "type"); var str = j.ToString (); Assert.AreEqual (str, "[1, 2, 3, null]"); + ((JsonArray) j).Add (null); + str = j.ToString (); + Assert.AreEqual (str, "[1, 2, 3, null, null]"); } // Test that we correctly serialize JsonObject with null elements. -- 2.25.1