当前位置: 首页 > news >正文

php装饰公司网站源码百度深圳总部

php装饰公司网站源码,百度深圳总部,移动端网站开发软件,网页设计与网站建设的区别json查看工具我已经开发了一个有用的工具插件,该插件可以接收JSON对象并呈现数据以在树层次结构中显示。 非常适合在大型JSON对象中查找节点的路径。 特征 通过上传JSON文件或复制和粘贴输入JSON。 可扩展树视图。 悬停节点以查看变量的路径。 单击以复制节点的…

json查看工具

json-tree-viewer-logo

我已经开发了一个有用的工具插件,该插件可以接收JSON对象并呈现数据以在树层次结构中显示。 非常适合在大型JSON对象中查找节点的路径。

特征

  • 通过上传JSON文件或复制和粘贴输入JSON。
  • 可扩展树视图。
  • 悬停节点以查看变量的路径。
  • 单击以复制节点的完整路径。
  • 为复制节点路径指定自定义定界符。


在线JSON树查看器工具

示例创建JSON树调用

如果要创建自己的树,则可以使用它们来创建它们。 JSONTREEVIEWER是主要的名称空间。

$(function () {//Initialise JQUERY4U JSON Tree ViewerJSONTREEVIEWER.init();//Events to load example files$('#example1').bind('click', function () {JSONTREEVIEWER.processJSONTree('one-level.json');});
});

处理JSON树的主要功能

此函数确定从何处获取JSON:1)文件上传; 或2)复制并粘贴; 3)示例文件。

/*Load the JSON file either by upload or example file and process tree*/
processJSONTree: function (filename) {$('#loading').show();var data = '',branches = '';if (filename === 'copyandpastejson') {var copypastejson = $('#copyandpastejson').val(); /*validate JSON*/if (JSONTREEVIEWER.isValidJSON(copypastejson)) {data = copypastejson;} else {return false;}if (data === false) {return false;} /*Build JSON Tree*/JSONTREEVIEWER.buildTree(JSONTREEVIEWER.processNodes(jQuery.parseJSON(data)), filename);} else {//get the JSON file from file upload$.ajax({type: 'GET',url: filename,async: false,beforeSend: function (x) {if (x && x.overrideMimeType) {x.overrideMimeType('application/j-son;charset=UTF-8');}},dataType: 'json',success: function (data) { /*Build JSON Tree*/JSONTREEVIEWER.buildTree(JSONTREEVIEWER.processNodes(data), filename);},error: function (e) { /*Invalid JSON*/alert('Invalid JSON: ' + e.responseText);JSONTREEVIEWER.showErrorMsg();return false;}});}
},

建立树功能

此功能从分支构造树并将其显示在页面上。

/*Build JSON Tree*/
buildTree: function (branches, filename) {//console.log('branches' + branches);if (typeof branches !== 'undefined' || branches !== '') {$('#browser').empty().html(branches);$('#browser').treeview({control: '#treecontrol',add: branches});$('#selected_filename').html('(' + filename + ')');$('#loading').hide();$('#browser-text').hide();} else {$('#selected_filename').html('Please select JSON file above...');$('#loading').hide();}
},

JSON分支递归函数

此功能相当复杂,需要花费一些时间进行编码。 它基本上以递归方式获取每个JSON对象,确定类型并为分支创建HTML。

/*Process each node by its type (branch or leaf)*/
processNodes: function (node) {var return_str = '';switch (jQuery.type(node)) {case 'string':if ($('#hierarchy_chk').is(':checked')) {return_str += '
  • ' + node + '
'; } else { return_str += '
  • ' + node + '
'; } break; case 'array': $.each(node, function (item, value) { return_str += JSONTREEVIEWER.processNodes(this); }); break; default: /*object*/ $.each(node, function (item, value) { if ($('#hierarchy_chk').is(':checked')) { return_str += '
  • ' + item + ' '; return_str += JSONTREEVIEWER.processNodes(this); return_str += '
'; } else { return_str += JSONTREEVIEWER.processNodes(this); } }); } /*Clean up any undefined elements*/ return_str = return_str.replace('undefined', ''); return return_str; },

检查JSON是否有效

Helper函数检查它们的JSON是否有效,并在无效时显示一条消息。

/*Helper function to check if JSON is valid*/
isValidJSON: function (jsonData) {try {jsonData = jQuery.parseJSON(jsonData);//console.log('valid json');return true;} catch (e) {//console.log('invalid json');alert(e);JSONTREEVIEWER.showErrorMsg();return false;}
},

获取节点路径

此函数以递归方式搜索HTML,以构造节点的分支路径。

/*jQuery function to create path function used to get the path of the node in the tree*/
jQuery.fn.extend({getPath: function (path) { /*The first time this function is called, path won't be defined*/if (typeof path == 'undefined') path = ''; /*Add the element name*/var cur = this.get(0).nodeName.toLowerCase();var id = this.attr('id'); /*Add the #id if there is one*/if (typeof id != 'undefined') { /*escape goat*/if (id == 'browser') {return path;}}var html = this.html();if (html.search('
  • ' + path); } else { return this.parent().getPath(path); } } });
  • 大事记

    当用户上传JSON文件或将鼠标悬停在树上时,一些用于处理事件的函数。

    /*change event when user changes file upload input*/
    $('#loadfile').live('change', function () {JSONTREEVIEWER.processJSONTree($(this).val());
    });/*store nodepath value to clipboard	(copy to top of page)*/
    $('#browser li').live('click', function () {var path = $('#pathtonode').html();var pathdelim = $('#pathdelim_chk').val();path = path.replace(/ > /g, pathdelim);JSONTREEVIEWER.addtoppath(path);
    });/*mouse IN hover to show path of node*/
    $('#browser li span').live('mouseenter', function () {$('#pathtonode').html(JSONTREEVIEWER.getNodePath(this));$('#pathtonode').show();
    });/*mouse OUT hover to show path of node*/
    $('#browser li span').live('mouseleave', function () {$('#pathtonode').empty();$('#pathtonode').hide();
    });

    要求

    我使用了jquery.treeview.async.js插件来创建可扩展树视图。

    下载源

    翻译自: https://www.sitepoint.com/online-json-tree-viewer/

    json查看工具

http://www.lbrq.cn/news/2667997.html

相关文章:

  • 厦门网站建设h5成年培训班有哪些
  • 湖南响应式网站建设推荐百度seo优化是做什么的
  • 各大网站rss订阅源地址百度收录关键词查询
  • 加强主流网站建设不要手贱搜这15个关键词
  • 推广策略和促销策略的区别正版seo搜索引擎
  • 公司找人做网站需要什么指数分布
  • 遵义做网站建设哪家公司好网络推广用什么软件好
  • 建设俄语网站杭州seo联盟
  • 有域名有空间怎么做网站网站排名分析
  • 建独立的网站seo搜索引擎优化推广专员
  • 服装市场网站建设推广产品的软文
  • 陕西建设厅特种作业报名入口国内好的seo网站
  • 下城区做网站产品推广活动策划方案
  • 用discuz做网站推广app的平台
  • 如何在网站后台备份数据库表广东东莞疫情最新情况
  • 大型网站解决方案设计百度软件安装
  • 餐饮行业做微信网站有什么好处影响seo排名的因素有哪些
  • 涞水网站建设站长工具樱花
  • 推荐一款男人都懂得app成都seo达人
  • 苏州网站开发外包公司互联网媒体推广
  • macbook air做网站seo网站排名优化快速排
  • wordpress固定链接文章发布失败重庆小潘seo
  • wordpress the_title() 字数巩义网站优化公司
  • 深圳建设网站和公众号电商培训心得
  • 找人做app网站吗在线seo外链工具
  • 个人站长网站应该如何定位百度关键词排名推广
  • 做网站好吗关键词是怎么排名的
  • 长沙市民警大人做爰网站昆山优化外包
  • 网站专业制作seo外链工具软件
  • 公司网站开发费用济南兴田德润简介图片廊坊快速排名优化
  • 18.WEB 服务器
  • Spring Boot - 内置的9个过滤器用法
  • 【走进Docker的世界】Docker环境搭建
  • H3C(基于Comware操作系统)与eNSP平台(模拟华为VRP操作系统)的命令差异
  • [论文阅读] 人工智能 + 软件工程 | 大型语言模型对决传统方法:多语言漏洞修复能力大比拼
  • 【C++详解】红黑树规则讲解与模拟实现(内附红黑树插入操作思维导图)