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

取得数据效果图:

原文地址:https://www.cnblogs.com/zhangchen/p/2266499.html