Commit a3e99fe1 authored by 黄奎's avatar 黄奎

新增验证

parent 2abd6a0d
...@@ -232,5 +232,28 @@ namespace Mall.Common.Plugin ...@@ -232,5 +232,28 @@ namespace Mall.Common.Plugin
); );
return JsonConvert.DeserializeObject(json); return JsonConvert.DeserializeObject(json);
} }
/// <summary>
/// 判断字符串是不是JSON格式
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
public static bool IsJson(string json)
{
bool flag = false;
if (!string.IsNullOrEmpty(json))
{
try
{
_ = (JObject)JsonConvert.DeserializeObject(json);
flag = true;
}
catch
{
flag = false;
}
}
return flag;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment