public static JsonDocument GetDocument(TextReader reader) { var jsonReader = new JsonReader(reader); var documentReader = new JsonDocumentReader(jsonReader); return documentReader.Load(); }
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)); } } }
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()); } } }
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); } }
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(); } }
public JsonDocumentReader(JsonReader reader) { this.reader = reader; }
public void CanHandleStreamError(string data) { using (TextReader stream = new StringReader(data)) { JsonReader reader = new JsonReader(stream); while (reader.Next()) { } Assert.True(reader.HasError); } }