Commits

Anonymous committed 5843a8b

Corrected string output to have literals in all lowercase.

Comments (0)

Files changed (7)

Json.Tests/Json/Extensions/XmlExtensionsTest.cs

 		public void RoundTrip_StartingWithXml()
 		{
 			var expected = XElement.Parse(@"<Requests><Request><SearchCustomerRequest xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://www.manatee.com/services/""><MachineName xmlns=""http://www.manatee.com/services/sub/"">USA02415-2</MachineName><SearchContext xmlns:d2p1=""http://www.manatee.com/services/""><d2p1:CustomerId i:nil=""true"" /><d2p1:EdgeId /><d2p1:EmailAddress /><d2p1:LastName /><d2p1:LoyaltyCardNumber>1234567890123</d2p1:LoyaltyCardNumber><d2p1:MaxRows i:nil=""true"" /><d2p1:PhoneNumber /><d2p1:ZipCode /></SearchContext></SearchCustomerRequest></Request></Requests>");
-			var expectedJson = JsonValue.Parse(@"{""Requests"":{""Request"":{""SearchCustomerRequest"":[{""-xmlns:i"":""http:\/\/www.w3.org\/2001\/XMLSchema-instance"",""-xmlns"":""http:\/\/www.manatee.com\/services\/""},{""MachineName"":[{""-xmlns"":""http:\/\/www.manatee.com\/services\/sub\/""},""USA02415-2""],""d2p1:SearchContext"":[{""-xmlns:d2p1"":""http:\/\/www.manatee.com\/services\/""},{""d2p1:CustomerId"":[{""-i:nil"":True},Null],""d2p1:EdgeId"":Null,""d2p1:EmailAddress"":Null,""d2p1:LastName"":Null,""d2p1:LoyaltyCardNumber"":1234567890123,""d2p1:MaxRows"":[{""-i:nil"":True},Null],""d2p1:PhoneNumber"":Null,""d2p1:ZipCode"":Null}]}]}}}");
+			var expectedJson = JsonValue.Parse(@"{""Requests"":{""Request"":{""SearchCustomerRequest"":[{""-xmlns:i"":""http:\/\/www.w3.org\/2001\/XMLSchema-instance"",""-xmlns"":""http:\/\/www.manatee.com\/services\/""},{""MachineName"":[{""-xmlns"":""http:\/\/www.manatee.com\/services\/sub\/""},""USA02415-2""],""d2p1:SearchContext"":[{""-xmlns:d2p1"":""http:\/\/www.manatee.com\/services\/""},{""d2p1:CustomerId"":[{""-i:nil"":true},null],""d2p1:EdgeId"":null,""d2p1:EmailAddress"":null,""d2p1:LastName"":null,""d2p1:LoyaltyCardNumber"":1234567890123,""d2p1:MaxRows"":[{""-i:nil"":true},null],""d2p1:PhoneNumber"":null,""d2p1:ZipCode"":null}]}]}}}");
 
 			var toJson = expected.ToJson();
 			Assert.AreEqual(expectedJson, toJson);

Json.Tests/Json/JsonArrayTest.cs

 		public void ToString_ReturnsCorrectString()
 		{
 			var json = new JsonArray {false, 42, "a string"};
-			var expected = "[False,42,\"a string\"]";
+			var expected = "[false,42,\"a string\"]";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		public void Parse_ValidString_ReturnsCorrectArray()
 		{
-			var s = "[False,42,\"a string\"]";
+			var s = "[false,42,\"a string\"]";
 			var expected = new JsonArray { false, 42, "a string" };
 			var i = 0;
 			var actual = new JsonArray(s, ref i);
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingValue_ThrowsJsonSyntaxException()
 		{
-			var s = "[False,,\"a string\"]";
+			var s = "[false,,\"a string\"]";
 			var i = 0;
 			var actual = new JsonArray(s, ref i);
 		}
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingOpenBracket_ThrowsJsonSyntaxException()
 		{
-			var s = "False,42,\"a string\"]";
+			var s = "false,42,\"a string\"]";
 			var i = 0;
 			var actual = new JsonArray(s, ref i);
 		}
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingCloseBracket_ThrowsJsonSyntaxException()
 		{
-			var s = "[False,42,\"a string\"";
+			var s = "[false,42,\"a string\"";
 			var i = 0;
 			var actual = new JsonArray(s, ref i);
 		}

Json.Tests/Json/JsonObjectTest.cs

 		public void ToString_ReturnsCorrectString()
 		{
 			var json = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-			var expected = "{\"bool\":False,\"int\":42,\"string\":\"a string\"}";
+			var expected = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		public void Parse_ValidString_ReturnsCorrectObject()
 		{
-			var s = "{\"bool\":False,\"int\":42,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
 			var expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
 			var actual = new JsonObject(s);
 			Assert.AreEqual(expected, actual);
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingValue_ThrowsJsonSyntaxException()
 		{
-			var s = "{\"bool\":False,\"int\":,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,\"int\":,\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingKey_ThrowsJsonSyntaxException()
 		{
-			var s = "{\"bool\":False,:42,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,:42,\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingKeyValue_ThrowsJsonSyntaxException()
 		{
-			var s = "{\"bool\":False,,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,,\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingKeyValueDelimiter_ThrowsJsonSyntaxException()
 		{
-			var s = "{\"bool\":False,\"int\"42,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,\"int\"42,\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonValueParseException))]
 		public void Parse_StringMissingDelimiter_ThrowsJsonValueParseException()
 		{
-			var s = "{\"bool\":False,\"int\":42\"string\":\"a string\"}";
+			var s = "{\"bool\":false,\"int\":42\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingOpenBrace_ThrowsJsonSyntaxException()
 		{
-			var s = "\"bool\":False,\"int\":42,\"string\":\"a string\"}";
+			var s = "\"bool\":false,\"int\":42,\"string\":\"a string\"}";
 			var actual = new JsonObject(s);
 		}
 		[TestMethod]
 		[ExpectedException(typeof(JsonSyntaxException))]
 		public void Parse_StringMissingCloseBrace_ThrowsJsonSyntaxException()
 		{
-			var s = "{\"bool\":False,\"int\":42,\"string\":\"a string\"";
+			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"";
 			var actual = new JsonObject(s);
 		}
 	}

Json.Tests/Json/JsonValueTest.cs

 			var json = JsonValue.Null;
 			var actual = json.Object;
 		}
-		//[TestMethod]
-		//public void Accessor_SetBoolWhenNotBool_ChangesTypeAndAssignsValue()
-		//{
-		//    var json = new JsonValue();
-		//    var expected = true;
-		//    json.Boolean = true;
-		//    Assert.AreEqual(JsonValueType.Boolean, json.Type);
-		//    Assert.AreEqual(expected, json.Boolean);
-		//}
-		//[TestMethod]
-		//public void Accessor_SetNumberWhenNotNumber_ChangesTypeAndAssignsValue()
-		//{
-		//    var json = new JsonValue();
-		//    var expected = 42;
-		//    json.Number = 42;
-		//    Assert.AreEqual(JsonValueType.Number, json.Type);
-		//    Assert.AreEqual(expected, json.Number);
-		//}
-		//[TestMethod]
-		//public void Accessor_SetStringWhenNotString_ChangesTypeAndAssignsValue()
-		//{
-		//    var json = new JsonValue();
-		//    var expected = "a string";
-		//    json.String = "a string";
-		//    Assert.AreEqual(JsonValueType.String, json.Type);
-		//    Assert.AreEqual(expected, json.String);
-		//}
-		//[TestMethod]
-		//public void Accessor_SetArrayWhenNotArray_ChangesTypeAndAssignsValue()
-		//{
-		//    var json = new JsonValue();
-		//    var expected = new JsonArray{false, 42, "a string"};
-		//    json.Array = new JsonArray {false, 42, "a string"};
-		//    Assert.AreEqual(JsonValueType.Array, json.Type);
-		//    Assert.AreEqual(expected, json.Array);
-		//}
-		//[TestMethod]
-		//public void Accessor_SetObjectWhenNotObject_ChangesTypeAndAssignsValue()
-		//{
-		//    var json = new JsonValue();
-		//    var expected = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-		//    json.Object = new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}};
-		//    Assert.AreEqual(JsonValueType.Object, json.Type);
-		//    Assert.AreEqual(expected, json.Object);
-		//}
 		#endregion
 
 		#region ToString Tests
 		public void ToString_BoolFalse_ReturnsCorrectString()
 		{
 			var json = new JsonValue(false);
-			var expected = "False";
+			var expected = "false";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		public void ToString_BoolTrue_ReturnsCorrectString()
 		{
 			var json = new JsonValue(true);
-			var expected = "True";
+			var expected = "true";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		public void ToString_Array_ReturnsCorrectString()
 		{
 			var json = new JsonValue(new JsonArray { false, 42, "a string" });
-			var expected = "[False,42,\"a string\"]";
+			var expected = "[false,42,\"a string\"]";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		public void ToString_Object_ReturnsCorrectString()
 		{
 			var json = new JsonValue(new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}});
-			var expected = "{\"bool\":False,\"int\":42,\"string\":\"a string\"}";
+			var expected = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		public void ToString_Null_ReturnsCorrectString()
 		{
 			var json = new JsonValue();
-			var expected = "Null";
+			var expected = "null";
 			var actual = json.ToString();
 			Assert.AreEqual(expected, actual);
 		}
 		[TestMethod]
 		public void Parse_StringWithBoolFalse_ReturnsCorrectJsonValue()
 		{
-			var s = "False";
+			var s = "false";
 			var expected = new JsonValue(false);
 			var actual = JsonValue.Parse(s);
 			Assert.AreEqual(expected, actual);
 		[TestMethod]
 		public void Parse_StringWithBoolTrue_ReturnsCorrectJsonValue()
 		{
-			var s = "True";
+			var s = "true";
 			var expected = new JsonValue(true);
 			var actual = JsonValue.Parse(s);
 			Assert.AreEqual(expected, actual);
 		[TestMethod]
 		public void Parse_StringWithArray_ReturnsCorrectJsonValue()
 		{
-			var s = "[False,42,\"a string\"]";
+			var s = "[false,42,\"a string\"]";
 			var expected = new JsonValue(new JsonArray {false, 42, "a string"});
 			var actual = JsonValue.Parse(s);
 			Assert.AreEqual(expected, actual);
 		[TestMethod]
 		public void Parse_StringWithObject_ReturnsCorrectJsonValue()
 		{
-			var s = "{\"bool\":False,\"int\":42,\"string\":\"a string\"}";
+			var s = "{\"bool\":false,\"int\":42,\"string\":\"a string\"}";
 			var expected = new JsonValue(new JsonObject {{"bool", false}, {"int", 42}, {"string", "a string"}});
 			var actual = JsonValue.Parse(s);
 			Assert.AreEqual(expected, actual);
 		[TestMethod]
 		public void Parse_StringWithNull_ReturnsCorrectJsonValue()
 		{
-			var s = "Null";
+			var s = "null";
 			var expected = JsonValue.Null;
 			var actual = JsonValue.Parse(s);
 			Assert.AreEqual(expected, actual);

Binary file modified.

Binary file modified.

Json/JsonValue.cs

 		{
 			switch (Type)
 			{
-				case JsonValueType.Number:
-				case JsonValueType.String:
-				case JsonValueType.Boolean:
-					return ToString();
 				case JsonValueType.Object:
 					return objectValue.GetIndentedString(indentLevel);
 				case JsonValueType.Array:
 					return arrayValue.GetIndentedString(indentLevel);
 				default:
-					return "Null";
+					return "null";
 			}
 		}
 
 				case JsonValueType.String:
 					return string.Format("\"{0}\"", InsertEscapeSequences(stringValue));
 				case JsonValueType.Boolean:
-					return string.Format("{0}", boolValue);
+					return boolValue ? "true" : "false";
 				case JsonValueType.Object:
 					return string.Format("{0}", objectValue);
 				case JsonValueType.Array:
 					return string.Format("{0}", arrayValue);
 				default:
-					return "Null";
+					return "null";
 			}
 		}
 		/// <summary>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.