![](https://csdnimg.cn/release/download_crawler_static/86381524/bg4.jpg)
/// <summary>
/// 对象转换为 Json 字符串
/// </summary>
/// <param name="jsonObject">对象</param>
/// <returns>Json 字符串</returns>
public static string ToJson(object jsonObject)
{
string jsonString = "{";
PropertyInfo[] propertyInfo = jsonObject.GetType().GetProperties();
for (int i = 0; i < propertyInfo.Length; i++)
{
object objectValue = propertyInfo[i].GetGetMethod().Invoke(jsonObject, null);
string value = string.Empty;
if (objectValue is DateTime || objectValue is Guid || objectValue is TimeSpan)
{
value = "'" + objectValue.ToString() + "'";
}
else if (objectValue is string)
{