JsonSQL: JSON parser, SQL style
Date : 2008 01 16 Category : Tech & DevelopmentTrent Richardson has released JsonSQL, a JavaScript library that allows you to muck around with JSON as though it is a datastore:
The API
PLAIN TEXT JAVASCRIPT:jsonsql.query("select * from json.channel.items order by title desc", json); jsonsql.query("select title,url from json.channel.items where (category=='javascript' || category=='vista') order by title,category asc limit 3", json);
Usage
Only Select statements are supported The requested fields may be a "*" or a list of fields. "*" is likely faster in most cases. When typing lists "select field1,field2,field3" or "limit 5,10 do not use spaces. When using the "where" clause enclose all conditions with one set of parenthesis "where (category=='The Category' || category=='Other Category')". The where clause is a javascript condition, not sql. It should use the scope emplied by "from". Javascript functions may be used here as well as javascript operators. The from clause should establish the scope you would like returned. It should start with "json" and use the dot notation: "json.channel.items" and should point to an array within the object. The order by option can accept a list but will only order by the first field at this time(asc,desc,ascnum,descnum).