Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sdk/core/Azure.Core.TestFramework/src/RecordEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ private void SerializeBody(Utf8JsonWriter jsonWriter, string name, byte[] reques

// We use array as a wrapper for string based serialization
// so if the root is an array we can't write it directly
// fallback to generic string writing
if (document.RootElement.ValueKind != JsonValueKind.Array)
// fallback to generic string writing. Also, if the root is a string
// we don't want to write it directly, as this would make matching
// not won't work in libraries that allow passing JSON as a string.
if (document.RootElement.ValueKind != JsonValueKind.Array &&
document.RootElement.ValueKind != JsonValueKind.String)
{
// Make sure we can replay JSON is exactly the same as the source
// for the case where service response was pre-formatted
Expand Down
1 change: 1 addition & 0 deletions sdk/core/Azure.Core/tests/RecordSessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class RecordSessionTests
[TestCase("{\"json\" :\"value\"}", "application/json")]
[TestCase("[\"json\", \"value\"]", "application/json")]
[TestCase("[{\"json\":\"value\"}, {\"json\":\"value\"}]", "application/json")]
[TestCase("\"\"", "application/json")]
[TestCase("invalid json", "application/json")]
[TestCase("{ \"json\": \"value\" }", "unknown")]
[TestCase("multi\rline", "application/xml")]
Expand Down