public void Setup() { var enumerableConverter = new JObjectConverter(); using var ms = new MemoryStream(); using (var writer = new Utf8JsonWriter(ms)) { var testObject = new JObject(new JProperty("id", 123), new JProperty("name", "test")); enumerableConverter.Write(writer, testObject, new JsonSerializerOptions()); } _result = System.Text.Encoding.UTF8.GetString(ms.ToArray()); }
public void Setup() { var enumerableConverter = new JObjectConverter(); using var ms = new MemoryStream(); using (var writer = new Utf8JsonWriter(ms)) { writer.WriteStartObject(); writer.WriteNumber("id", 123); writer.WriteString("name", "test"); writer.WriteEndObject(); } var json = System.Text.Encoding.UTF8.GetString(ms.ToArray()); var reader = new Utf8JsonReader(ms.ToArray()); reader.Read(); _result = enumerableConverter.Read(ref reader, typeof(JObject), new JsonSerializerOptions()); }