Skip to content

Commit 3acd7f7

Browse files
committed
Add condition to return json as string
A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string.
1 parent 704d4cd commit 3acd7f7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public async Task<object> ReadAsync(Stream content, Type? returnType, Cancellati
3030

3131
using var reader = new StreamReader(content, leaveOpen: true);
3232
var json = await reader.ReadToEndAsync();
33+
34+
if(returnType == typeof(string))
35+
return json;
3336

3437
if (returnType == null || returnType.IsPrimitive)
3538
return json.ConvertTo(returnType ?? typeof(string))!;

0 commit comments

Comments
 (0)