Example #1
0
        public void op_Object_string_whenNullValue()
        {
            const string name = "name";

            var document = new JsonObject
                               {
                                   new JsonPair(name, new JsonNull())
                               };

            Assert.Null(document.Object(name));
        }
Example #2
0
        public void op_ReadJson_JsonReader(string json)
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write(json);
                    writer.Flush();
                    stream.Position = 0;
                    using (var reader = new JsonReader(stream))
                    {
                        reader.Read();

                        var obj = new JsonObject();
                        obj.ReadJson(reader);

                        Assert.Equal("value", obj.String("name").Value);
                        Assert.Equal("1", obj.Array("range").Number(0).Value);
                        Assert.Equal("2", obj.Array("range").Number(1).Value);
                        Assert.Equal("3", obj.Array("range").Number(2).Value);
                        Assert.Equal("123", obj.Number("id").Value);
                        Assert.True(obj.Boolean("visible"));
                        Assert.False(obj.Boolean("enabled"));
                        Assert.Null(obj.String("check"));
                        Assert.Equal("1.23", obj.Object("child").Number("value").Value);
                    }
                }
            }
        }
Example #3
0
        public void op_Object_string()
        {
            const string name = "name";
            var expected = new JsonObject();

            var document = new JsonObject
                               {
                                   new JsonPair(name, expected)
                               };

            var actual = document.Object(name);

            Assert.Equal(expected, actual);
        }