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文件:
    		
    		:输出文件样式文件
    		
    		

    取得数据效果图:

  • 相关阅读:
    Django REST Framework之版本控制
    Django REST Framework之频率限制
    webpack4进阶配置
    高阶函数map,filter,reduce的用法
    Vue+elementui 实现复杂表头和动态增加列的二维表格
    Pika源码学习--pika和rocksdb的对接
    Pika源码学习--pika的命令执行框架
    Pika源码学习--pika的PubSub机制
    Pika源码学习--pika的通信和线程模型
    pika源码学习--开篇
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2266499.html
Copyright © 2011-2022 走看看