From 3acd7f7c1e13b174b6a53f52e406793d3ff76851 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 29 Dec 2023 11:35:15 +0100 Subject: [PATCH] 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. --- src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs b/src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs index ad2906c49e..4f2ee9bba1 100644 --- a/src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs +++ b/src/modules/Elsa.Http/Parsers/JsonHttpContentParser.cs @@ -30,6 +30,9 @@ public async Task ReadAsync(Stream content, Type? returnType, Cancellati using var reader = new StreamReader(content, leaveOpen: true); var json = await reader.ReadToEndAsync(); + + if(returnType == typeof(string)) + return json; if (returnType == null || returnType.IsPrimitive) return json.ConvertTo(returnType ?? typeof(string))!;