Dictionary<string, object> dictionary = JSONToObject<Dictionary<string, object>>(Str);


public static T JSONToObject<T>(string jsonText)
{
    T local;
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    try
    {
        local = serializer.Deserialize<T>(jsonText);
    }
    catch (Exception exception)
    {
        throw new Exception(exception.Message);
    }
    return local;
}

 

 

public static string ObjectToJSON(object obj)
{
    string str;
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    try
    {
        str = serializer.Serialize(obj);
    }
    catch (Exception exception)
    {
        throw new Exception(emYpxP33xAq8jO8oJ1.eopWKtZX1(0) + exception.Message);
    }
    return str;
}

 

public static List<Dictionary<string, object>> DataTableToList(DataTable dt)
{
    List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
    foreach (DataRow row in dt.Rows)
    {
        Dictionary<string, object> item = new Dictionary<string, object>();
        foreach (DataColumn column in dt.Columns)
        {
            item.Add(column.ColumnName, row[column.ColumnName]);
        }
        list.Add(item);
    }
    return list;
}
 

相关文章:

  • 2022-12-23
  • 2021-08-30
  • 2021-10-05
  • 2021-12-26
  • 2021-10-29
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2021-07-25
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案