public void ReadAsIntDecimal() { string json = @"{""Name"": 1.1}"; JsonTextReader reader = new JsonTextReader(new StringReader(json)); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.StartObject, reader.TokenType); Assert.IsTrue(reader.Read()); Assert.AreEqual(JsonToken.PropertyName, reader.TokenType); reader.ReadAsInt32(); Assert.AreEqual(JsonToken.Integer, reader.TokenType); Assert.AreEqual(typeof(int), reader.ValueType); Assert.AreEqual(1, reader.Value); }
public void ReadOctalNumberAsInt32() { StringReader s = new StringReader(@"[0372, 0xFA, 0XFA]"); JsonTextReader jsonReader = new JsonTextReader(s); Assert.IsTrue(jsonReader.Read()); Assert.AreEqual(JsonToken.StartArray, jsonReader.TokenType); jsonReader.ReadAsInt32(); Assert.AreEqual(JsonToken.Integer, jsonReader.TokenType); Assert.AreEqual(typeof(int), jsonReader.ValueType); Assert.AreEqual(250, jsonReader.Value); jsonReader.ReadAsInt32(); Assert.AreEqual(JsonToken.Integer, jsonReader.TokenType); Assert.AreEqual(typeof(int), jsonReader.ValueType); Assert.AreEqual(250, jsonReader.Value); jsonReader.ReadAsInt32(); Assert.AreEqual(JsonToken.Integer, jsonReader.TokenType); Assert.AreEqual(typeof(int), jsonReader.ValueType); Assert.AreEqual(250, jsonReader.Value); Assert.IsTrue(jsonReader.Read()); Assert.AreEqual(JsonToken.EndArray, jsonReader.TokenType); Assert.IsFalse(jsonReader.Read()); }