• JsonSQL:用SQL语句解析JSON文件


         下午没事干,到处闲逛发现一个好玩的东东,发出来与大家共享,哈哈。。。一个解析JSON的插件,

    用SQL语法,当然只能用简单的条件查询咯,不过这个用起比较简单,容易上手,废话不多说下面就上code:

    Dome下载:JsonSQL Dome下载

    这编辑器不知道咋用,效果可能运行不了。。。不过有个Dome,需要的下载玩玩。。。

    运行示例:


    语句1: jsonsql.query("select * from json.channel.items order by title desc",json);


    语句2: jsonsql.query("select title,url from json.channel.items where (category=='javascript' || category=='vista') order by title,category asc limit 3",json);


    语句3:jsonsql.query("select url from json.channel.items where (category=='javascript' && author=='trent') order by url asc limit 1,2",json);


    参数详解:

    只支持 Select 查询语句,“JSON”:“json.channel.items”指向一个对象数组, 排序接受参数:asc,desc,ascnum,descnum, limit:接受1,或2个参数,指定要获取数据数量个数。

    		调用JS方法:
    
    			function getAll(){
    				$.getJSON("testjson.js", function(json){
    					dump(jsonsql.query("select * from json.channel.items order by title desc,json",json));
    				});
    			}
    
    			function getFiltered(){
    				$.getJSON("testjson.js", function(json){
    					dump(jsonsql.query("select title,url,author,category from json.channel.items where (category=='javascript' || author=='trent') order by title,category asc limit 3",json));
    				});
    			}
    
    			function getLimit(){
    				$.getJSON("testjson.js", function(json){
    					dump(jsonsql.query("select url from json.channel.items where (category=='javascript' && author=='trent') order by url asc limit 1,2",json));
    				});
    			}
    		
    		调用外部JS文件:
    		
    		:输出文件样式文件
    		
    		

    取得数据效果图:

  • 相关阅读:
    SPOJ
    SPOJ LCS Longest Common Substring(后缀自动机)题解
    HihoCoder1445 后缀自动机二·重复旋律5(后缀自动机 子串种数)
    eclipse 常用设置
    读取Request body方法
    pom.xml实例
    powerdesign连接Oracle&Mysql
    Json常用操作
    Spring MVC POM示例
    FreeMaker常用表达式
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2266499.html
Copyright © 2020-2023  润新知