如何在jQuery中获得预期的json值
How to get expected json value in jQuery?
我正在制作json后观看json对象,但我得到更多的关键或文本。我需要删除该文本。
我得到这个输出
function mapItem(inputItem) {
var item = {};
item[inputItem.id] = JSON.parse(sessionStorage.getItem(inputItem.id));
for (k in inputItem.children) {
if (/^not-/.test(inputItem.children[k].id)) {
item[inputItem.id].commandList.push(mapItem(inputItem.children[k]));
}else{
item[inputItem.id].testCaseList.push(mapItem(inputItem.children[k]));
}
}
return item;
}
http://jsfiddle.net/tJ7Kq/7/我认为这一行有问题
item[inputItem.id].commandList.push(mapItem(inputItem.children[k]));
试试这个
http://jsfiddle.net/tJ7Kq/8/function mapItem(inputItem) {
//var item = {};
var item = JSON.parse(sessionStorage.getItem(inputItem.id));
for (k in inputItem.children) {
if (/^not-/.test(inputItem.children[k].id)) {
item.commandList.push(mapItem(inputItem.children[k]));
}else{
item.testCaseList.push(mapItem(inputItem.children[k]));
}
}
return item;
}
相关文章:
- 解析复杂的json-jquery
- 我应该使用哪个:json-jquery 或 json2.js
- php请求带有多个对象json-jquery
- JSON JQUERY未捕获类型错误:无法读取属性'长度'的未定义
- 在多层json Jquery中循环
- JSON / JQUERY - ajax post,如何在成功函数中处理 XML 数据
- Json jQuery 和 php 处理的值不正确
- JSON/jQuery/PHP:未捕获语法错误:意外的令牌:
- 缓存通过PHP/AAJX/JSON/jQuery加载的动态图像
- JSON Jquery大小写不敏感匹配
- 接收数据json/jquery
- Javascript json jquery无法获得自定义属性值
- Rails 3和Ajax/JSON/JQuery/直接DOM更新-与Scaffold程序一起使用
- 简单的模式JSON Jquery
- 迭代表列&构建JSON - jQuery
- 基于ID生成锚链接(JSON, jQuery)
- JSON jQuery数据变量
- get JSON - JQuery & PHP
- Ajax更改为JSON (Jquery离线+ Manifest) -离线web应用程序
- 尝试使用JSON - jQuery上传多个数据.为什么不工作呢?