.net 解析json格式数据

xiaoxiao2021-02-28  26

            string funcInfo = "";             string json = "[{\"funcscope_category\":{\"id\":1}},{\"funcscope_category\":{\"id\":15}}]";             JArray jarryFuncInfo = (JArray)JsonConvert.DeserializeObject(json);             if (jarryFuncInfo != null && jarryFuncInfo.Count > 0)             {                 for (int i = 0; i < jarryFuncInfo.Count; i++)                 {                     JObject objFunc = (JObject)jarryFuncInfo[i];                     funcInfo += objFunc["funcscope_category"]["id"] + ",";                 }             }

            Response.Write(funcInfo);

             int id = 0;             string json02 = "{\"id\": 2 }";             JObject jarry02 = (JObject)JsonConvert.DeserializeObject(json02);             if (jarry02 != null && jarry02.Count > 0)             {                 id = Convert.ToInt32(jarry02["id"]);             }             Response.Write(id);

转载请注明原文地址: https://www.6miu.com/read-1950400.html

最新回复(0)