Use char instead of string for DetectJson (#13019)

* Use char instead of string for DetectJson

* Use faster method

* Change DetectIsJon method
This commit is contained in:
patrickdemooij9
2022-09-30 01:39:54 +02:00
committed by GitHub
parent 826dbe7d62
commit ae5a8496bb
2 changed files with 72 additions and 2 deletions

View File

@@ -129,8 +129,7 @@ public static class StringExtensions
}
input = input.Trim();
return (input.StartsWith("{") && input.EndsWith("}"))
|| (input.StartsWith("[") && input.EndsWith("]"));
return (input[0] is '[' && input[^1] is ']') || (input[0] is '{' && input[^1] is '}');
}
public static bool DetectIsEmptyJson(this string input) =>