/// <summary> /// Creates a new <see cref="ReorderingJsonReader"/> and advances it to the first property node /// </summary> /// <param name="json">The json string to potentially reorder and read.</param> /// <returns>The created json reader.</returns> private static ReorderingJsonReader CreateReorderingReaderPositionedOnFirstProperty(string json) { var reader = new ReorderingJsonReader(new StringReader(json), maxInnerErrorDepth: 0, isIeee754Comaptible: true); reader.NodeType.Should().Be(JsonNodeType.None); reader.Read(); reader.NodeType.Should().Be(JsonNodeType.StartObject); reader.Read(); reader.NodeType.Should().Be(JsonNodeType.Property); return(reader); }
/// <summary> /// Creates a new <see cref="ReorderingJsonReader"/> and advances it to the first property node /// </summary> /// <param name="json">The json string to potentially reorder and read.</param> /// <returns>The created json reader.</returns> private static ReorderingJsonReader CreateReorderingReaderPositionedOnFirstProperty(string json) { var stringReader = new StringReader(json); var innerReader = new JsonReader(stringReader, isIeee754Compatible: true); var reader = new ReorderingJsonReader(innerReader, maxInnerErrorDepth: 0); Assert.Equal(JsonNodeType.None, reader.NodeType); reader.Read(); Assert.Equal(JsonNodeType.StartObject, reader.NodeType); reader.Read(); Assert.Equal(JsonNodeType.Property, reader.NodeType); return(reader); }
private async Task SetupReorderingJsonReaderAndRunTestAsync( string payload, Func <ReorderingJsonReader, Task> func) { using (var stringReader = new StringReader(payload)) { using (var jsonReader = new JsonReader(stringReader, isIeee754Compatible: false)) { var reorderingReader = new ReorderingJsonReader(jsonReader, maxInnerErrorDepth: 0); await reorderingReader.ReadAsync(); // Position the reader on the first node await reorderingReader.ReadAsync(); // Read StartObject await func(reorderingReader); } } }