diff --git a/src/AutoWrapper/Extensions/StringExtension.cs b/src/AutoWrapper/Extensions/StringExtension.cs index 14bb35b..02ff60a 100644 --- a/src/AutoWrapper/Extensions/StringExtension.cs +++ b/src/AutoWrapper/Extensions/StringExtension.cs @@ -29,6 +29,10 @@ public static bool IsValidJson(this string text) public static (bool IsEncoded, string ParsedText) VerifyBodyContent(this string text) { + if(!IsValidJsonText(text)) + { + return (false, text); + } try { var obj = JToken.Parse(text); @@ -56,6 +60,18 @@ public static string ToCamelCase(this string str) } return str; } + + private static bool IsValidJsonText(string text) + { + if(string.IsNullOrWhiteSpace(text)) + { + return false; + } + bool startsWithBrace = text.StartsWith("{") && text.EndsWith("}"); + bool startsWithBracket = text.StartsWith("[") && text.EndsWith("]"); + + return startsWithBrace || startsWithBracket; + } } }