Example #1
0
        public static JsonDocument GetDocument(TextReader reader)
        {
            var jsonReader = new JsonReader(reader);
            var documentReader = new JsonDocumentReader(jsonReader);

            return documentReader.Load();
        }
Example #2
0
        public void CanReadNumberValue(string data, decimal value)
        {
            using (TextReader stream = new StringReader(data))
            {
                JsonReader reader = new JsonReader(stream);

                while (reader.Next())
                {
                    Assert.Equal(value, Decimal.Parse(reader.Token.GetString(), NumberStyles.Float, CultureInfo.InvariantCulture));
                }
            }
        }
Example #3
0
        public void CanReadTextValue(string data, string value)
        {
            using (TextReader stream = new StringReader(data))
            {
                JsonReader reader = new JsonReader(stream);

                while (reader.Next())
                {
                    Assert.Equal(value, reader.Token.GetString());
                }
            }
        }
Example #4
0
        public void CanReadData(string data)
        {
            using (TextReader stream = new StringReader(data))
            {
                JsonReader reader = new JsonReader(stream);

                while (reader.Next())
                {
                    Assert.False(reader.HasError);
                }

                Assert.False(reader.HasError);
            }
        }
Example #5
0
        private static JsonSchema GetSchema(string name)
        {
            Assembly assembly = typeof(JsonSchema).Assembly;
            string fullName = $"Resources.{name}";

            using (Stream stream = assembly.GetManifestResourceStream(typeof(JsonSchema), fullName))
            using (TextReader reader = new StreamReader(stream))
            {
                var jsonReader = new JsonReader(reader);
                var documentReader = new JsonDocumentReader(jsonReader);
                var document = documentReader.Load();
                var schemaReader = new JsonSchemaReader(document);

                return schemaReader.Load();
            }
        }
Example #6
0
 public JsonDocumentReader(JsonReader reader)
 {
     this.reader = reader;
 }
Example #7
0
        public void CanHandleStreamError(string data)
        {
            using (TextReader stream = new StringReader(data))
            {
                JsonReader reader = new JsonReader(stream);

                while (reader.Next()) { }

                Assert.True(reader.HasError);
            }
        }