允许对JSON数据进行类似SQL查询的Javascript库? [英] Javascript libraries that allow for SQL-like queries on JSON data?

查看:651
本文介绍了允许对JSON数据进行类似SQL查询的Javascript库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们的JSON数据来自单个MySQL表:

Say our JSON data comes from a single MySQL table:

someJSON =    [ { name: 'bill' , sex:'M', income:50000 },
                { name: 'sara' , sex:'F', income:100000 },
                 ...
               ];

并说伪代码是:

获取所有性别的所有人物对象: 收入> 60000`。

"Get all the person objects of all sex:F of income > 60000`".

是否有任何javascript库允许用户使用类似SQL或SQL的语法对此JSON数据进行此类查询编码。

Are there any javascript libraries that would allow one to code such queries on this JSON data using a SQL or SQL-like syntax.

如果您感到好奇,请注意以下几点:

In case you are curious, some context:

我正在为我的组织制作数据分析Web服务的前端知道未来的后端会是什么。将来,他们会将数据从MS Access表迁移到某种MySQL类型的数据库。在那之前,我正在使用静态JSON文件来开始开发,并且认为将来我们的javascript查询显示为MySQL查询可能会对他们有所帮助。 (当前的MS Access数据库无法从网络上访问。)

I am making the front-end of a data analysis web service for my organization without knowing what the future backend will be. In the future they will migrate their data from MS Access tables to some-sort of MySQL-type database. Until then I am using static JSON files to start development and was thinking it may be helpful for them in the future to have my javascript queries appear as MySQL queries. (The current MS Access database is unreachable from the web.)

推荐答案

查看 jslinq

var myList = [
            {FirstName:"Chris",LastName:"Pearson"},
            {FirstName:"Kate",LastName:"Johnson"},
            {FirstName:"Josh",LastName:"Sutherland"},
            {FirstName:"John",LastName:"Ronald"},
            {FirstName:"Steve",LastName:"Pinkerton"}
            ];

var exampleArray = JSLINQ(myList)
                   .Where(function(item){ return item.FirstName == "Chris"; })
                   .OrderBy(function(item) { return item.FirstName; })
                   .Select(function(item){ return item.FirstName; });

这篇关于允许对JSON数据进行类似SQL查询的Javascript库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆