using system;using system.collections.generic;
using system.text;
using system.reflection;
using system.data;
using system.collections;
namespace aimscommon
string _temp = sb.tostring().trimend(',');
_temp += "]";
return _temp;
}/// /// 泛型介面轉json
///
///
///
///
/// ]}
public static string ilisttojson(ilistlist, string classname)
string _temp = sb.tostring().trimend(',');
_temp += "]}";
return _temp;
}/// /// 物件轉json
///
///
///
///
public static string objecttojson(t t)
json = sb.tostring().trimend(',');
json += "}";
}return json;
}/// /// 物件轉json(過載)
///
///
///
///
/// ]}
public static string objecttojson(t t, string classname)
json = sb.tostring().trimend(',');
json += "}]}";
}return json;
}/// /// list轉成json
///
///
///
///
///
public static string objecttojson(ilistil, string jsonname)
}if (i < il.count - 1)}}
return json.tostring();
}/// /// 將陣列轉換為json格式的字串
///
/// 資料型別,如string,int ...
/// 泛型list
/// json的類名
///
public static string arraytojson(listlist, string propertyname)
string _temp = sb.tostring();
_temp = _temp.trimend(',');
_temp += "]}]";
return _temp;
}else
return "";
}/// /// datatable轉json
///
/// table資料集
/// json名
///
public static string datatabletojson(datatable dt, string dtname)
sb = sb.remove(sb.length - 1, 1);
}sb = sb.remove(sb.length - 1, 1);
}return jsoncharfilter(sb.tostring());
}/// /// 資料行轉json
///
/// 資料行
///
public static string datarowtojson(datarow dr)
sb = sb.remove(0, sb.length - 1);
return sb.tostring();
}/// /// 陣列轉json
///
///
///
public static string arraytojson(string strs)
if (sb.length > 0)
return "";
return "";
}#region listtojson
/// /// list 轉換json格式
///
/// 類名
/// list集合
///
public static string listtojson(listobjlist, string jsonname)
result += "\"" + jsonname + "\":[";
//處理第一行前面不加","號
bool firstline = true;
foreach (object oo in objlist)
else
}return result + "]}";
}/// /// 單個物件轉換json
///
/// 物件
///
private static string objecttojson(object o)
else
}return result + "}";
}/// /// 獲取物件屬性
///
/// 物件
///
private static listgetobjectproperty(object o)
return propertyslist;
}#endregion
public static string hashtabletojson(hashtable data, string dtname)
else
}sb = sb.remove(sb.length - 1, 1);
return jsoncharfilter(sb.tostring());
}/// /// json特符字元過濾
///
/// 要過濾的源字串
/// 返回過濾的字串
private static string jsoncharfilter(string sourcestr)
}}
C 物件資料轉換Json幫助類 JsonHelp
c 物件資料轉換json幫助類 jsonhelp using system using system.data using system.configuration using system.web using system.web.security using system.web.ui usin...
json 格式轉換
datarow 轉換成json格式 public static string tojson datarow drrights jsonbuilder.remove jsonbuilder.length 1,1 jsonbuilder.remove jsonbuilder.length 1,1 ret...
c 通用json幫助類
using system using system.data using system.text using system.collections.generic using system.reflection using system.data.common using system.collec...