json简单格式转树状结构 工具方法
来源:互联网 发布:广告公司用到的软件 编辑:程序博客网 时间:2024/06/09 21:23
/** * json简单格式转树状结构 工具方法 * * @param jsondata * json数据 * @param idStr * id的字符串 * @param pidStr * 父id的字符串 * @param childrenStr * children的字符串 * @return {Array} 数组 */function transData(jsondata, idStr, pidStr, childrenStr) { var r = [], hash = {}, id = idStr, pid = pidStr, children = childrenStr, i = 0, j = 0, len = jsondata.length; for(; i < len; i++){ hash[jsondata[i][id]] = jsondata[i]; } for(; j < len; j++){ var aVal = jsondata[j], hashVP = hash[aVal[pid]]; if(hashVP){ !hashVP[children] && (hashVP[children] = []); hashVP[children].push(aVal); }else{ r.push(aVal); } } return r; }
0 0
- json简单格式转树状结构 工具方法
- json转json树状结构
- json转树状结构(js)
- json转树状结构(js)
- 【知识记录】json转树状结构(js)
- 检查Json格式工具
- 复杂格式JSON转普通JSON工具类
- 简单的对象转json格式
- Json 格式简单学习
- Json格式简单说
- json格式简单理解
- 简单json格式拼接
- PHP 生成复杂JSON格式 简单快速方法
- php json格式简单封装接口方法并调用
- 树形结构JSON的实现方法(也叫做JSON嵌套格式)
- String转json简单方法
- 集合转json格式方法封装
- json编写格式方法
- Android驱动中的Kconfig文件与Makefile文件
- 样式表以及Color.xml文件『Android系列六』
- Oracle错误代码大全
- IOS UITableView
- 乐视笔试题
- json简单格式转树状结构 工具方法
- android:screenOrientation的说明
- PHP运行模式(cgi,fast-cgi,cli,web模块模式及php-fpm说明)
- Android的AlarmManager服务
- MyEclipse的调试技巧
- JVM Class 文件结构详解二
- SVN客户端的使用
- AFnetworking框架存储cookie和使用cookie请求总结
- Java中String类型笔试题目,对象声明与创建及在内存中的存贮