Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  153] [ 4]  / answers: 1 / hits: 30418  / 14 Years ago, tue, january 18, 2011, 12:00:00

Say our JSON data comes from a single MySQL table:



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


And say the pseudo-code is:



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



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:



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.)


More From » jquery

 Answers
29

Check out 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; });

[#94178] Sunday, January 16, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sophiak

Total Points: 242
Total Questions: 90
Total Answers: 103

Location: Liechtenstein
Member since Wed, Dec 8, 2021
3 Years ago
;