public void ParseEmptyString() { JsonLiteObjectBase obj = parser.TryParse(String.Empty); Assert.AreEqual(true, obj != null); Assert.AreEqual("{}", obj.ToDebugString()); }
public void ParseMixedItemArray() { JsonLiteObjectBase obj = parser.TryParse("[[\"test\"],{\"property\":\"passed\"},\"value\"]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[[\"test\"],\r\n{\"property\":\"passed\"},\r\n\"value\"]", obj.ToDebugString()); obj = parser.TryParse(" [ [ \"test\" ] , { \"property\" : \"passed\" } , \"value\" ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[[\"test\"],\r\n{\"property\":\"passed\"},\r\n\"value\"]", obj.ToDebugString()); }
public void ParseMultiArrayItemArray() { JsonLiteObjectBase obj = parser.TryParse("[[\"test\"],[\"passed\"]]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[[\"test\"],\r\n[\"passed\"]]", obj.ToDebugString()); obj = parser.TryParse(" [ [ \"test\" ] , [ \"passed\" ] ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[[\"test\"],\r\n[\"passed\"]]", obj.ToDebugString()); }
public void ParseMultiObjectItemArray() { JsonLiteObjectBase obj = parser.TryParse("[{\"property\":\"value\"},{\"property2\":\"value2\"}]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[{\"property\":\"value\"},\r\n{\"property2\":\"value2\"}]", obj.ToDebugString()); obj = parser.TryParse(" [ { \"property\" : \"value\" } , { \"property2\" : \"value2\" } ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[{\"property\":\"value\"},\r\n{\"property2\":\"value2\"}]", obj.ToDebugString()); }
public void ParseMultiStringItemArray() { JsonLiteObjectBase obj = parser.TryParse("[\"test\",\"passed\",true,20.3,null]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"test\",\r\n\"passed\",\r\n\"true\",\r\n\"20.3\",\r\n\"null\"]", obj.ToDebugString()); obj = parser.TryParse(" [ \"test\" , \"passed\" , true , 20.3 , null ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"test\",\r\n\"passed\",\r\n\"true\",\r\n\"20.3\",\r\n\"null\"]", obj.ToDebugString()); }
public void ParseEmptyArray() { JsonLiteObjectBase obj = parser.TryParse("[]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[]", obj.ToDebugString()); obj = parser.TryParse(" [ ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[]", obj.ToDebugString()); }
public void ParseMixed() { JsonLiteObjectBase obj = parser.TryParse("{\"property\":[\"innerProperty\",\"innerValue\"],\"property1\":{\"innerProperty\":\"ivalue\"},\"property2\":\"value2\"}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":[\"innerProperty\",\r\n\"innerValue\"],\r\n\"property1\":{\"innerProperty\":\"ivalue\"},\r\n\"property2\":\"value2\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : [ \"innerProperty\" , \"innerValue\" ] , \"property1\" : { \"innerProperty\" : \"ivalue\" } , \"property2\" : \"value2\" } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":[\"innerProperty\",\r\n\"innerValue\"],\r\n\"property1\":{\"innerProperty\":\"ivalue\"},\r\n\"property2\":\"value2\"}", obj.ToDebugString()); }
public void ParseNestedArray() { JsonLiteObjectBase obj = parser.TryParse("{\"property\":[\"innerProperty\",\"innerValue\"]}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":[\"innerProperty\",\r\n\"innerValue\"]}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : [ \"innerProperty\" , \"innerValue\" ] } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":[\"innerProperty\",\r\n\"innerValue\"]}", obj.ToDebugString()); }
public void ParseSeveralStringValues() { JsonLiteObjectBase obj = parser.TryParse("{\"property\":\"value\",\"property1\":\"value1\",\"property2\":\"value2\"}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"value\",\r\n\"property1\":\"value1\",\r\n\"property2\":\"value2\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : \"value\" , \"property1\" : \"value1\" , \"property2\" : \"value2\" } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"value\",\r\n\"property1\":\"value1\",\r\n\"property2\":\"value2\"}", obj.ToDebugString()); obj = parser.TryParse("{\"property\":true,\"property1\":false,\"property2\":null}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"true\",\r\n\"property1\":\"false\",\r\n\"property2\":\"null\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : true , \"property1\" : false , \"property2\" : null } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"true\",\r\n\"property1\":\"false\",\r\n\"property2\":\"null\"}", obj.ToDebugString()); }
public void ParseSimpleValue() { JsonLiteObjectBase obj = parser.TryParse("{\"property\":\"value\"}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"value\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : \"value\" } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"value\"}", obj.ToDebugString()); obj = parser.TryParse("{\"property\":\"va \\\\\\r\\n\\t\\b\\f\\/lue\"}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"va \\\r\n\t\b\f/lue\"}", obj.ToDebugString()); obj = parser.TryParse("{\"property\":true}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"true\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : true } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"true\"}", obj.ToDebugString()); obj = parser.TryParse("{\"property\":null}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"null\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : null } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"null\"}", obj.ToDebugString()); obj = parser.TryParse("{\"property\":1.5}"); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"1.5\"}", obj.ToDebugString()); obj = parser.TryParse(" { \"property\" : 1.5 } "); Assert.AreEqual(true, obj != null); Assert.AreEqual("{\"property\":\"1.5\"}", obj.ToDebugString()); }
public void ParseSingleItemArray() { JsonLiteObjectBase obj = parser.TryParse("[\"test\"]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"test\"]", obj.ToDebugString()); obj = parser.TryParse(" [ \"test\" ] "); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"test\"]", obj.ToDebugString()); obj = parser.TryParse("[true]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"true\"]", obj.ToDebugString()); obj = parser.TryParse("[20.3]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"20.3\"]", obj.ToDebugString()); obj = parser.TryParse("[null]"); Assert.AreEqual(true, obj != null); Assert.AreEqual("[\"null\"]", obj.ToDebugString()); }