Ejemplo n.º 1
0
Archivo: Json.cs Proyecto: rhemm23/bolt
        public static object Deserialize(Type type, string json)
        {
            StringReader       stringReader = new StringReader(json);
            JsonReaderDirector director     = new JsonReaderDirector(stringReader);

            return(director.ReadValue().BuildObject(type));
        }
Ejemplo n.º 2
0
        public void TestWhitespace()
        {
            const string       json     = "    {  \"test_key\"    :   null }      \n \r \t  \f     ";
            JsonReaderDirector director = new JsonReaderDirector(new StringReader(json));
            JsonObject         obj      = (JsonObject)director.ReadValue();

            // Assert key
            IJsonValue val;

            if (!obj.TryGetValue("test_key", out val))
            {
                Assert.Fail("Expected key in JsonObject named 'test_key'");
            }

            // Assure value
            if (!(val is JsonNull))
            {
                Assert.Fail("Expected value for key 'test_key' in JsonObject to be null");
            }
        }