如题:我需要一个方法
public string GetJsonFromList(List<object> list){ _________ return "[{},{}]";}
这里关键是我的参数可能是一个强类型的list,并且不确定,有可能是类型A也有可能是类型B,我应该怎么做呢
微信里点“发现”,扫一下
二维码便可将本文分享至朋友圈。
public string GetJsonFromList(List<T> list){ JavascriptSerializer}
用json.net
有现成的函数
下载Newtonsoft.Json Dll,引用
public string GetJsonFromList(List<object> list){ _________ return Newtonsoft.Json.JavaScriptConvert.SerializeObject(list); }