zoukankan      html  css  js  c++  java
  • 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文件:
    		
    		:输出文件样式文件
    		
    		

    取得数据效果图:

  • 相关阅读:
    并发与并行的区别
    Java 中的JSON 字符串
    java spark list 转为 RDD 转为 dataset 写入表中
    SparkConf和SparkContext
    Java 中清空map
    java JSON的使用和解析
    presto计算日期间隔天数或者小时间隔——date_diff函数使用
    Nginx 负载均衡配置
    Nginx 反向代理配置示例(conf文件配置)
    前端同学 linux常用指令汇总
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2266499.html
Copyright © 2011-2022 走看看