public void GetMiBooksBuy(string IDUser) { LibrosDAO DAOLibros = new LibrosDAO(); DataTable dt = new DataTable(); dt = DAOLibros.ConsultarBiblotecaUsuario(IDUser); System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >(); Dictionary <string, object> row; foreach (DataRow dr in dt.Rows) { row = new Dictionary <string, object>(); foreach (DataColumn col in dt.Columns) { row.Add(col.ColumnName, dr[col]); } rows.Add(row); } //string test = serializer.Serialize(rows); Context.Response.Write(serializer.Serialize(rows)); }