Thu 20 Dec 2007
I’ve been playing with JSON a bit lately and it seems there’s not a lot of options for searching JSON such as the way xpath can search XML. Since there aren’t any slick libraries out there I have been thinking on possibilities of creating such. Would it be slick to have an sql-like syntax parse and search json? You could then do something like so:
select name,age from people where age > 20 order by name limit 5
After thinking it through its basically a nice regex to parse out the query, then just pass the arguments to a function to parse it. Being one who interacts with sql on a regular basis this seems quite appealing, especially if you have an html table to sort or there are a million other possibilites! I havn’t done this but I have played with the regular expression to do such. Also the same principle could apply to XML, but it would be rather pointless with xpath.

December 21st, 2007 at 12:45 pm
That would be slick for bundling with an ajax request to whitelist what data you did want from say a third party json api like yahoo or whoever. just a thought, but definitely could be neat in more ways that just having a search.
December 23rd, 2007 at 1:21 pm
I thought so as well. Inefficiencies would be the biggest issue like the “order by” when you have thousands of entries with javascript. That being said the user would need to realize the limitations, but you rarely would want to handle anything that large with js in the first place.
December 24th, 2007 at 6:34 am
Brings up a good point about using an html table to store the data in and sort it using similar methods to table sorters already built out there. is the footprint of an unattached dom element larger than that of a js var? I don’t know, but it’s interesting in theory if nothing else.
December 24th, 2007 at 10:33 am
I hope in the next couple weeks I can twiddle with this idea. It may be the situation if it is inefficient its usability out weights its slowness.
January 29th, 2008 at 12:57 am
I stumbled across this just before I got to your site, perhaps it will be useful to you:
http://jsdb.sourceforge.net/usarho.html
January 29th, 2008 at 7:52 am
That project looks very interesting.. and possibly a bit more database like as I was just shooting for the sql-like parsing. Also an update to this post; I did implement this project.
http://trentrichardson.com/jsonsql/