feat: 新增string扩展函数 IsJsonString (#19)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-07-02 11:02:41 +08:00
committed by GitHub
parent 301154a66c
commit 32b7bdf700
6 changed files with 95 additions and 90 deletions

View File

@ -358,6 +358,26 @@ public static class StringExtensions
return lastEqualSignPos == me.Length - 1 && me[firstEqualSignPos..lastEqualSignPos].All(x => x == '=');
}
/// <summary>
/// 是否json字符串
/// </summary>
/// <param name="me">me</param>
public static bool IsJsonString(this string me)
{
if (me.NullOrEmpty()) {
return false;
}
try {
_ = JsonDocument.Parse(me);
}
catch {
return false;
}
return true;
}
/// <summary>
/// 中文姓名打马赛克
/// </summary>