ASP.NET 将后台返回得到的JSON 转换为数组

问题描述

我的json元数据是varjsondata=[{"QuestionId":1,"QuestionName":"Satisfaction","QuestionDescription":"Satisfaction","LanguageViewModel":[{"LanguageId":1,"languageCode":"bg","StatusName":"Updated"},{"LanguageId":2,"languageCode":"cs","StatusName":"Updated"},{"LanguageId":3,"languageCode":"da","StatusName":"Updated"},{"LanguageId":4,"languageCode":"de","StatusName":"Updated"},{"LanguageId":5,"languageCode":"el","StatusName":"Updated"},{"LanguageId":6,"languageCode":"en","StatusName":"Updated"},{"LanguageId":7,"languageCode":"es","StatusName":"Updated"},{"LanguageId":8,"languageCode":"et","StatusName":"Updated"},{"LanguageId":9,"languageCode":"fi","StatusName":"Updated"},{"LanguageId":10,"languageCode":"fr","StatusName":"Updated"},{"LanguageId":11,"languageCode":"he","StatusName":"Updated"},{"LanguageId":12,"languageCode":"hi","StatusName":"Updated"},{"LanguageId":13,"languageCode":"hr","StatusName":"Updated"},{"LanguageId":14,"languageCode":"hu","StatusName":"Updated"},{"LanguageId":15,"languageCode":"it","StatusName":"Updated"},{"LanguageId":16,"languageCode":"ja","StatusName":"Updated"},{"LanguageId":17,"languageCode":"ko","StatusName":"Updated"},{"LanguageId":18,"languageCode":"lt","StatusName":"Updated"},{"LanguageId":19,"languageCode":"lv","StatusName":"Updated"},{"LanguageId":20,"languageCode":"ms","StatusName":"Updated"},{"LanguageId":21,"languageCode":"nl","StatusName":"Updated"},{"LanguageId":22,"languageCode":"no","StatusName":"Updated"},{"LanguageId":23,"languageCode":"pl","StatusName":"Updated"},{"LanguageId":24,"languageCode":"pt","StatusName":"Updated"},{"LanguageId":25,"languageCode":"pt-br","StatusName":"Updated"},{"LanguageId":26,"languageCode":"ro","StatusName":"Updated"},{"LanguageId":27,"languageCode":"ru","StatusName":"Updated"},{"LanguageId":28,"languageCode":"sk","StatusName":"Updated"},{"LanguageId":29,"languageCode":"sl","StatusName":"Updated"},{"LanguageId":30,"languageCode":"sv","StatusName":"Updated"},{"LanguageId":31,"languageCode":"th","StatusName":"Updated"},{"LanguageId":32,"languageCode":"tr","StatusName":"Updated"},{"LanguageId":33,"languageCode":"zh-sim","StatusName":"Updated"},{"LanguageId":34,"languageCode":"zh-tra","StatusName":"Updated"},{"LanguageId":35,"languageCode":"ar-me","StatusName":"Updated"},{"LanguageId":36,"languageCode":"zh-hk","StatusName":"Updated"},{"LanguageId":37,"languageCode":"fr-ca","StatusName":"ToBeLocalized"}]}];

我要的结果是将分别添加到数组中<scripttype="text/javascript">$(function(){varjsondata=[{"QuestionId":1,"QuestionName":"Satisfaction","QuestionDescription":"Satisfaction","LanguageViewModel":[{"LanguageId":1,"languageCode":"bg","StatusName":"Updated"},{"LanguageId":2,"languageCode":"cs","StatusName":"Updated"},{"LanguageId":3,"languageCode":"da","StatusName":"Updated"},{"LanguageId":4,"languageCode":"de","StatusName":"Updated"},{"LanguageId":5,"languageCode":"el","StatusName":"Updated"},{"LanguageId":6,"languageCode":"en","StatusName":"Updated"},{"LanguageId":7,"languageCode":"es","StatusName":"Updated"},{"LanguageId":8,"languageCode":"et","StatusName":"Updated"},{"LanguageId":9,"languageCode":"fi","StatusName":"Updated"},{"LanguageId":10,"languageCode":"fr","StatusName":"Updated"},{"LanguageId":11,"languageCode":"he","StatusName":"Updated"},{"LanguageId":12,"languageCode":"hi","StatusName":"Updated"},{"LanguageId":13,"languageCode":"hr","StatusName":"Updated"},{"LanguageId":14,"languageCode":"hu","StatusName":"Updated"},{"LanguageId":15,"languageCode":"it","StatusName":"Updated"},{"LanguageId":16,"languageCode":"ja","StatusName":"Updated"},{"LanguageId":17,"languageCode":"ko","StatusName":"Updated"},{"LanguageId":18,"languageCode":"lt","StatusName":"Updated"},{"LanguageId":19,"languageCode":"lv","StatusName":"Updated"},{"LanguageId":20,"languageCode":"ms","StatusName":"Updated"},{"LanguageId":21,"languageCode":"nl","StatusName":"Updated"},{"LanguageId":22,"languageCode":"no","StatusName":"Updated"},{"LanguageId":23,"languageCode":"pl","StatusName":"Updated"},{"LanguageId":24,"languageCode":"pt","StatusName":"Updated"},{"LanguageId":25,"languageCode":"pt-br","StatusName":"Updated"},{"LanguageId":26,"languageCode":"ro","StatusName":"Updated"},{"LanguageId":27,"languageCode":"ru","StatusName":"Updated"},{"LanguageId":28,"languageCode":"sk","StatusName":"Updated"},{"LanguageId":29,"languageCode":"sl","StatusName":"Updated"},{"LanguageId":30,"languageCode":"sv","StatusName":"Updated"},{"LanguageId":31,"languageCode":"th","StatusName":"Updated"},{"LanguageId":32,"languageCode":"tr","StatusName":"Updated"},{"LanguageId":33,"languageCode":"zh-sim","StatusName":"Updated"},{"LanguageId":34,"languageCode":"zh-tra","StatusName":"Updated"},{"LanguageId":35,"languageCode":"ar-me","StatusName":"Updated"},{"LanguageId":36,"languageCode":"zh-hk","StatusName":"Updated"},{"LanguageId":37,"languageCode":"fr-ca","StatusName":"ToBeLocalized"}]}];vardataQuestion=[];$(eval(jsondata)).each(function(){//格式为,\QuestionId,QuestionName,QuestionDescription,LanguageViewModel为其key//例如QuestionId的Key对应的值就是1,QuestionName的key对应的值就是Satisfaction});

解决方案

解决方案二:
eval之后不就是数组了么?
解决方案三:
楼主的意思是想只取到key还是?
解决方案四:
没看懂
解决方案五:
用这个JavaScriptSerializer
解决方案六:
vartest=[];$(eval(jsondata)).each(function(item){test.push(item.的QuestionId);});
解决方案七:
varas=$.parseJSON(jsondata);将的到的json数据反序列化过来for(i=0;i<a.length;i++){vara=as[i];a.id;//取得对应id}

时间: 2024-09-29 04:33:14

ASP.NET 将后台返回得到的JSON 转换为数组的相关文章

ajax请求时间太长,后台返回json,前台无反应。

问题描述 ajax请求时间太长,后台返回json,前台无反应. 1C 由于后台运算会花费较长时间(大概4.5分钟),这个时间一旦较长,再返回Json给页面时页面就没反应了.`` $.ajaxFileUpload({ url : $(this).attr(""action"") secureuri : false formObj : $(this) append_data : { 'datemonth' : datemonthImport } dataType : '

ajax接受后台返回的json数据不全

问题描述 ajax接受后台返回的json数据不全 后面没东西了 导致ajax直接进入error方法了知道的大神帮忙支支招 , 万分感谢 解决方案 网络不稳定导致数据没有传输完吧...你浏览器直接访问地址能获取到完整的数据没? 解决方案二: 你先检查后台组织json的地方是否组织了正确的数据 解决方案三: 如果是你在后台自己封装的json对象,需要考虑容错,不要因为某一项异常或导致了返回的对象不是一个完整的Json对象.最好是先取值,最后统一封装,而不是动态拼接这种形式,极易出错. 解决方案四:

后台返回json数据,提示下载保存

问题描述 使用ajax方式提交表单function simpleAjaxForm(formName, check){$("#" + formName).ajaxForm({dataType: "json",beforeSubmit: function(){var msg = check ? validator(check) : null;if(msg) dialogBox(msg);return msg ? false : true;},success: funct

显示-求教将后台返回的JSON数据填充到表格的问题,js的循环怎么写才正确。

问题描述 求教将后台返回的JSON数据填充到表格的问题,js的循环怎么写才正确. 后台返回的是这样的 {"reportId":"1","className":"java","reportName":"232","teaName":"刘老师","stuName":"张同学","uploadDate&q

我的ASP网站登录后台,访问返回了200,怎么解决

问题描述 我的ASP网站登录后台,访问返回了200,怎么解决 解决方案 解决方案二:200是什么,如果是htrpstatuscode的话,200就是服务器正确响应了解决方案三:我可以加你的QQ私聊的吗解决方案四: 解决方案五:引用3楼zxb478846231的回复:这个看你的浏览器控制台输出的什么错误.

js+ajax处理java后台返回的json对象循环创建到表格的方法_AJAX相关

本文实例讲述了js+ajax处理java后台返回的json对象循环创建到表格的方法.分享给大家供大家参考,具体如下: //注:LO是表格的id: 需要自己创建表头, n行,9列的表格: var tab_id; function varify(cardinno) { tab_id=document.getElementById("Layer1"); displayDiv(); tab_id.style.display="none"; var url="get

js+ajax处理java后台返回的json对象循环创建到表格的方法

本文实例讲述了js+ajax处理java后台返回的json对象循环创建到表格的方法.分享给大家供大家参考,具体如下: //注:LO是表格的id: 需要自己创建表头, n行,9列的表格: var tab_id; function varify(cardinno) { tab_id=document.getElementById("Layer1"); displayDiv(); tab_id.style.display="none"; var url="get

ajax asp net-ajax AccordionPane后台添加后为什么客户端显示的样式是隐藏的

问题描述 ajax AccordionPane后台添加后为什么客户端显示的样式是隐藏的 代码如下: aspx页面: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %> <%@ Register Assembly="AjaxControlToolkit" Namesp

javaScript如何处理从java后台返回的list_javascript技巧

事情: 从java后台返回List<String>类型数据,用于界面显示.但js中想获取它并操作它.直接使用EL表达式,js把它识别成字符串了.不是我想要的啊..网上搜了搜大家的解决方案...最好的当然是把List集合转成json格式传到界面上.这样js里面操作也简单,页面也没有影响. 解决: 将List<String> 转成json,传到界面.js中使用var arr = eval('${list}');将list转成js数组. 我的代码: 复制代码 代码如下: var keyL