当前位置: 首页>>代码示例>>C#>>正文


C# Script.Serialization.JavaScriptSerializer.Deserialize方法代码示例

本文整理汇总了C#中System.Web.Script.Serialization.JavaScriptSerializer.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# Script.Serialization.JavaScriptSerializer.Deserialize方法的具体用法?C# Script.Serialization.JavaScriptSerializer.Deserialize怎么用?C# Script.Serialization.JavaScriptSerializer.Deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Script.Serialization.JavaScriptSerializer的用法示例。


在下文中一共展示了Script.Serialization.JavaScriptSerializer.Deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: About

        public ActionResult About(string searchString)
        {
            if(searchString=="" || searchString==null)
            {
                searchString = "Jurasic Park";
            }

               List<Movie> mo = new List<Movie>();

                string responseString = "";
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://localhost:51704/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = client.GetAsync("api/movie?name=" + searchString).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        responseString = response.Content.ReadAsStringAsync().Result;
                    }
                }

                string jsonInput=responseString; //

                System.Console.Error.WriteLine(responseString);

                JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                mo= jsonSerializer.Deserialize<List<Movie>>(jsonInput);
            return View(mo);
        }
开发者ID:nantharupan,项目名称:MVC_MovieSearch,代码行数:30,代码来源:HomeController.cs

示例2: LoadFavorites

        private void LoadFavorites()
        {
            try
            {
                string url = string.Format("http://api.mixcloud.com/{0}/favorites/", txtUsername.Text.Trim());

                WebRequest wr = WebRequest.Create(url);
                wr.ContentType = "application/json; charset=utf-8";
                Stream stream = wr.GetResponse().GetResponseStream();
                if (stream != null)
                {
                    StreamReader streamReader = new StreamReader(stream);
                    string jsonString = streamReader.ReadToEnd();

                    var jsonSerializer = new JavaScriptSerializer();
                    RootObject rootObject = jsonSerializer.Deserialize<RootObject>(jsonString);
                    rptFavorites.DataSource = rootObject.data;
                    rptFavorites.DataBind();

                    divFavorites.Visible = rootObject.data.Any();
                    divMessage.Visible = !divFavorites.Visible;
                }
            }
            catch (Exception ex)
            {
            }
        }
开发者ID:baturaymutlu,项目名称:Mixcloud-Favorites,代码行数:27,代码来源:default.aspx.cs

示例3: GetTestCases

        public static TestCaseInfo[] GetTestCases(string data) {
            var serializer = new JavaScriptSerializer();
            List<TestCaseInfo> tests = new List<TestCaseInfo>();
            foreach (var item in serializer.Deserialize<object[]>(data)) {
                var dict = item as Dictionary<string, object>;
                if (dict == null) {
                    continue;
                }

                object filename, className, methodName, startLine, startColumn, endLine, kind;
                if (dict.TryGetValue(Serialize.Filename, out filename) &&
                    dict.TryGetValue(Serialize.ClassName, out className) &&
                    dict.TryGetValue(Serialize.MethodName, out methodName) &&
                    dict.TryGetValue(Serialize.StartLine, out startLine) &&
                    dict.TryGetValue(Serialize.StartColumn, out startColumn) &&
                    dict.TryGetValue(Serialize.EndLine, out endLine) &&
                    dict.TryGetValue(Serialize.Kind, out kind)) {
                    tests.Add(
                        new TestCaseInfo(
                            filename.ToString(),
                            className.ToString(),
                            methodName.ToString(),
                            ToInt(startLine),
                            ToInt(startColumn),
                            ToInt(endLine)
                        )
                    );
                }
            }
            return tests.ToArray();
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:31,代码来源:TestAnalysisExtension.cs

示例4: GetMessageByUser

        public RootObjectOut GetMessageByUser(UserIn jm)
        {
            RootObjectOut output = new RootObjectOut();
            String jsonString = "";
            try
            {
                String strConnection = ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
                SqlConnection Connection = new SqlConnection(strConnection);
                String strSQL = string.Format("SELECT message FROM messages WHERE msgTo = '{0}' AND [msgID] = (SELECT MAX(msgID) FROM messages WHERE msgTo='{1}')", jm.user.ToString(),jm.user.ToString());
                SqlCommand Command = new SqlCommand(strSQL, Connection);
                Connection.Open();
                SqlDataReader Dr;
                Dr = Command.ExecuteReader();
                if (Dr.HasRows)
                {
                    if (Dr.Read())
                    {
                        jsonString = Dr.GetValue(0).ToString();
                    }
                }
                Dr.Close();
                Connection.Close();
            }
            catch (Exception ex)
            {
                output.errorMessage = ex.Message;
            }
            finally
            {
            }
            JavaScriptSerializer ser = new JavaScriptSerializer();
            output = ser.Deserialize<RootObjectOut>(jsonString);

            return output;
        }
开发者ID:kincade71,项目名称:is670,代码行数:35,代码来源:Get.cs

示例5: loadVentas

        public void loadVentas()
        {
            List<Venta> lv = new List<Venta>();
            var javaScriptSerializer = new JavaScriptSerializer();
            string jsonVentas = "";

            Ventas serv = new Ventas();
            serv.Url = new Juddi().getServiceUrl("Ventas");
            jsonVentas = serv.getVentas((int)Session["Id"]);
            lv = javaScriptSerializer.Deserialize<List<Venta>>(jsonVentas);
            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[7] {
                        new DataColumn("id", typeof(int)),
                                        new DataColumn("tipo", typeof(string)),
                                        new DataColumn("autor",typeof(string)),
                                        new DataColumn("estado",typeof(string)),
                                        new DataColumn("fechafin",typeof(string)),
                                        new DataColumn("pujamax",typeof(int)),
                                        new DataColumn("pujar",typeof(string))
                    });
            for (int i = 0; i < lv.Count; i++)
            {
                dt.Rows.Add(lv[i].id, lv[i].tipo, lv[i].autor, lv[i].estado, lv[i].fecha_F, lv[i].precio, "Pujar");
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
开发者ID:shadowlink,项目名称:SOR-Project,代码行数:27,代码来源:ListaPujas.aspx.cs

示例6: GetDealClosingCostTypesFromDeepBlue

 public static List<DeepBlue.Models.Entity.DealClosingCostType> GetDealClosingCostTypesFromDeepBlue(CookieCollection cookies)
 {
     // Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc
     List<DeepBlue.Models.Entity.DealClosingCostType> dealClosingCostTypes = new List<DeepBlue.Models.Entity.DealClosingCostType>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc");
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, null, false, cookies, false, HttpWebRequestUtil.JsonContentType);
     if (response.StatusCode == System.Net.HttpStatusCode.OK) {
         using (Stream receiveStream = response.GetResponseStream()) {
             // Pipes the stream to a higher level stream reader with the required encoding format.
             using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {
                 string resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     FlexigridData flexiGrid = (FlexigridData)js.Deserialize(resp, typeof(FlexigridData));
                     foreach (Helpers.FlexigridRow row in flexiGrid.rows) {
                         DeepBlue.Models.Entity.DealClosingCostType dealClosingType = new DeepBlue.Models.Entity.DealClosingCostType();
                         dealClosingType.DealClosingCostTypeID = Convert.ToInt32(row.cell[0]);
                         dealClosingType.Name = Convert.ToString(row.cell[1]);
                         dealClosingCostTypes.Add(dealClosingType);
                     }
                 }
                 else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return dealClosingCostTypes;
 }
开发者ID:jsingh,项目名称:DeepBlue,代码行数:31,代码来源:DealImport.cs

示例7: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string strResult = Commons.StringHelper.JsonOutString(false, "分类保存失败!");
            string action = Commons.WebPage.PageRequest.GetFormString("action");
            string str = Commons.WebPage.PageRequest.GetFormString("classifyIds");
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List<int> listClassifys = new List<int>();
            if (str != "")
            {
                listClassifys = serializer.Deserialize<List<int>>(str);
            }

            str = Commons.WebPage.PageRequest.GetFormString("productsIds");
            List<int> listPros = new List<int>();
            if (str != "")
            {
                listPros = serializer.Deserialize<List<int>>(str);
            }
            if (action.ToLower() == "product")
            {
                if (allotProducts(listPros, listClassifys))
                {
                    strResult = Commons.StringHelper.JsonOutString(true, "分类保存成功!");
                }
            }
            else
            {

            }
            context.Response.Write(strResult);
        }
开发者ID:skywolfkun,项目名称:MyCode,代码行数:32,代码来源:allotClassify.ashx.cs

示例8: Main

        public static void Main()
        {
            var serializer = new JavaScriptSerializer();
            
            var place = Place.GetTestPlace();

            var jsonPlace = serializer.Serialize(place);

            Console.WriteLine("JSON place: ");
            Console.WriteLine(jsonPlace);
            Console.WriteLine();

            Console.WriteLine("Original place: ");
            Console.WriteLine(place);
            Console.WriteLine();

            var deserializedPlace = serializer.Deserialize<Place>(jsonPlace);
            Console.WriteLine("Deserialized place: ");
            Console.WriteLine(deserializedPlace);

            // Wrong behavior
            var deserializedCategory = serializer.Deserialize<Category>(jsonPlace);
            Console.WriteLine("Deserialized wrong category: ");
            Console.WriteLine(deserializedCategory);
        }
开发者ID:syssboxx,项目名称:Database-Applications,代码行数:25,代码来源:Program.cs

示例9: buscarItem

        public string buscarItem(string dtoChave, string dtoProduto, string dtoEstabelecimento)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            DtoRetorno retorno = new DtoRetorno("ACK");
            DtoChave chave = js.Deserialize<DtoChave>(dtoChave);
            DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto);
            DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEstabelecimento);

            Chave mChave = new Chave();

            try
            {
                mChave.validarChave(chave);
                Item mItem = new Item();
                DtoItem item = mItem.abrirItem(produto.id, enderecoEstabelecimento.id);
                chave = mChave.atualizarChave(chave);
                retorno = new DtoRetornoObjeto(chave, item);
            }
            catch (DtoExcecao ex)
            {
                retorno = ex.ToDto();
            }
            catch (Exception ex)
            {
                retorno = new DtoRetornoErro(ex.Message);
            }

            /*Objeto: DtoItem com DtoProduto com DtoTipoProduto e DtoFabricante*/
            return js.Serialize(retorno);
        }
开发者ID:jonnathanBruno,项目名称:catalog,代码行数:30,代码来源:ControllerProduto.cs

示例10: abrirProduto

        public string abrirProduto(string dtoChave, string dtoProduto)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            DtoRetorno retorno = new DtoRetorno("ACK");
            DtoChave chave = js.Deserialize<DtoChave>(dtoChave);
            Chave mChave = new Chave();

            try
            {
                mChave.validarChave(chave);
                DtoProduto produto = js.Deserialize<DtoProduto>(dtoProduto);
                Produto mProduto = new Produto();
                produto = mProduto.abrirProduto(produto.id);
                chave = mChave.atualizarChave(chave);
                retorno = new DtoRetornoObjeto(chave, produto);
            }
            catch (DtoExcecao ex)
            {
                retorno = ex.ToDto();
            }
            catch (Exception ex)
            {
                retorno = new DtoRetornoErro(ex.Message);
            }

            /*Objeto: DtoProduto com DtoTipoProduto e DtoFabricante*/
            return js.Serialize(retorno);
        }
开发者ID:jonnathanBruno,项目名称:catalog,代码行数:28,代码来源:ControllerProduto.cs

示例11: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            JsonBE jsonObject = new JsonBE();
            FirstStep firstStep = new FirstStep();

            firstStep.ApplicationQuadri = "IPRI";
            firstStep.ITFNumber = "ITF123";
            firstStep.DeltaOrFull = "0";

            Collection<String> colString = new Collection<String>();

            colString.Add("0");
            colString.Add("1");
            colString.Add("2");

            firstStep.Deliverables = colString;
            firstStep.Environments = colString;

            jsonObject.Step1 = firstStep;

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

            var ser = jsSerializer.Serialize(jsonObject);

            var test = context.Request.Form[0];

            var test2 = jsSerializer.Deserialize<JsonBE>(ser);

            var test3 = jsSerializer.Deserialize<JsonBE>(test);

            context.Response.ContentType = "text/plain";
            context.Response.Write(ser);
        }
开发者ID:shaanino,项目名称:dmt,代码行数:33,代码来源:AjaxHandler.ashx.cs

示例12: GetApps

        public void GetApps()
        {
            var jss = new JavaScriptSerializer();

            string loginJSON = "{user:'" + UserName + "', password:'" + Password + "'}";
            Centrify_API_Interface centLogin = new Centrify_API_Interface().MakeRestCall(CentLoginURL, loginJSON);
            Dictionary<string, dynamic> loginData = jss.Deserialize<Dictionary<string, dynamic>>(centLogin.returnedResponse);

            //To pass a specific user name if you log in as an admin.
            //string appsJSON = "{username:'" + strUserName + "'}";
            string appsJSON = @"{""force"":""True""}";
            Centrify_API_Interface centGetApps = new Centrify_API_Interface().MakeRestCall(CentGetAppsURL, appsJSON, centLogin.returnedCookie);           
            Dictionary<string, dynamic> getAppsData = jss.Deserialize<Dictionary<string, dynamic>>(centGetApps.returnedResponse);

            var dApps = getAppsData["Result"]["Apps"];
            string strAuth = loginData["Result"]["Auth"];

            int iCount = 0;

            foreach (var app in dApps)
            {
                string strDisplayName = app["DisplayName"];
                string strAppKey = app["AppKey"];
                string strIcon = app["Icon"];

                AddUrls(strAppKey, strDisplayName, strIcon, iCount, strAuth);

                iCount++;
            }
        }
开发者ID:erajsiddiqui,项目名称:CentrifyAPIExamples_CS,代码行数:30,代码来源:GetUpData.cs

示例13: adicionarProduto

        /*Não Implementado*/
        public string adicionarProduto(string dtoChave, string dtoLista, string dtoProdutoDaLista)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            DtoRetorno retorno;
            DtoChave chave = js.Deserialize<DtoChave>(dtoChave);
            DtoLista lista = js.Deserialize<DtoLista>(dtoLista);

            Chave mChave = new Chave();

            try
            {
                mChave.validarChave(chave);
                DtoProdutoDaLista produtoDaLista = js.Deserialize<DtoProdutoDaLista>(dtoProdutoDaLista);
                Lista mLista = new Lista();
                produtoDaLista = mLista.adicionarProduto(produtoDaLista);
                chave = mChave.atualizarChave(chave);
                retorno = new DtoRetornoObjeto(chave, produtoDaLista);
            }
            catch (DtoExcecao ex)
            {
                retorno = ex.ToDto();
            }
            catch (Exception ex)
            {
                retorno = new DtoRetornoErro(ex.Message);
            }

            /*Objeto: DtoProdutoDaLista com o DtoProduto*/
            return js.Serialize(retorno);
        }
开发者ID:jonnathanBruno,项目名称:catalog,代码行数:31,代码来源:ControllerLista.cs

示例14: criarEstabelecimento

        public string criarEstabelecimento(string dtoChave, string dtoEnderecoEstabelecimento)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            DtoRetorno retorno;
            DtoChave chave = js.Deserialize<DtoChave>(dtoChave);
            DtoEnderecoEstabelecimento enderecoEstabelecimento = js.Deserialize<DtoEnderecoEstabelecimento>(dtoEnderecoEstabelecimento);
            DtoEnderecoEstabelecimento estabelecimento;

            Chave mChave = new Chave();

            try
            {
                mChave.validarChave(chave);
                Estabelecimento mEstabelecimento = new Estabelecimento();
                estabelecimento = mEstabelecimento.cadastrarEstabelecimento(enderecoEstabelecimento);
                chave = mChave.atualizarChave(chave);
                retorno = new DtoRetornoObjeto(chave, estabelecimento);
            }
            catch (DtoExcecao ex)
            {
                retorno = ex.ToDto();
            }
            catch (Exception ex)
            {
                retorno = new DtoRetornoErro(ex.Message);
            }

            /*Objeto: DtoEnderecoEstabelecimento com DtoEstabelecimento*/
            return js.Serialize(retorno);
        }
开发者ID:jonnathanBruno,项目名称:catalog,代码行数:30,代码来源:ControllerEstabelecimento.cs

示例15: Reload

        public void Reload(XElement element)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            BrowserSourceSettings = AbstractSettings.DeepClone(BrowserSettings.Instance.SourceSettings);
            BrowserInstanceSettings = AbstractSettings.DeepClone(BrowserSettings.Instance.InstanceSettings);

            String instanceSettingsString = element.GetString("instanceSettings");
            String sourceSettingsString = element.GetString("sourceSettings");

            if (sourceSettingsString != null && sourceSettingsString.Count() > 0)
            {
                try
                {
                    BrowserSourceSettings = serializer.Deserialize<BrowserSourceSettings>(sourceSettingsString);
                }
                catch (ArgumentException e)
                {
                    API.Instance.Log("Failed to deserialized source settings and forced to recreate; {0}", e.Message);
                }
            }

            if (instanceSettingsString != null && instanceSettingsString.Count() > 0)
            {
                BrowserInstanceSettings.MergeWith(serializer.Deserialize<BrowserInstanceSettings>(instanceSettingsString));
            }
        }
开发者ID:jameshearn,项目名称:CLRBrowserSourcePlugin,代码行数:27,代码来源:BrowserConfig.cs


注:本文中的System.Web.Script.Serialization.JavaScriptSerializer.Deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。