C# 对象转JSON和json转对象(转出为dynamic的对象)
作者:互联网
/// <summary> /// json转换工具 /// </summary> public class JsonTools { /// <summary> /// 对象转JSON /// </summary> /// <param name="obj"></param> /// <returns></returns> public static string ObjectToJson(object obj) { return JsonConvert.SerializeObject(obj); } /// <summary> /// JSON转对象 ,获得dynamic类型的对象 /// </summary> /// <param name="jsonString"></param> /// <returns></returns> public static dynamic JsonToObject(string jsonString) { return JsonConvert.DeserializeObject<dynamic>(jsonString); } }
标签:对象,dynamic,JsonConvert,C#,JSON,static,public 来源: https://www.cnblogs.com/lijianhong90/p/10588455.html