<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Trent Richardson &#187; JsonSQL</title> <atom:link href="http://trentrichardson.com/category/jsonsql/feed/" rel="self" type="application/rss+xml" /><link>http://trentrichardson.com</link> <description>practical web design &#38; development</description> <lastBuildDate>Wed, 25 Jan 2012 11:43:16 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>New Demo &#8211; Impromptu with Ajax</title><link>http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/</link> <comments>http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/#comments</comments> <pubDate>Wed, 04 Mar 2009 03:01:34 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Impromptu]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JsonSQL]]></category> <category><![CDATA[Programming]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=268</guid> <description><![CDATA[I&#8217;ve had several users ask about using Impromptu with ajax to pull in content. I myself far more pull in json to build my content for Impromptu. So I figured I&#8217;d kill two birds with one stone by creating an example of using Ajax to pull in JSON content, then build a select statement with [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2009/02/24/new-impromptu-and-demo/' rel='bookmark' title='New Impromptu and Demo'>New Impromptu and Demo</a></li><li><a
href='http://trentrichardson.com/2008/11/25/impromptu-an-ajax-form-framework/' rel='bookmark' title='Impromptu: An Ajax Form Framework'>Impromptu: An Ajax Form Framework</a></li><li><a
href='http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/' rel='bookmark' title='Introducing JsonSQL 0.1'>Introducing JsonSQL 0.1</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve had several users ask about using <a
href="http://trentrichardson.com/Impromptu/index.php" title="jQuery Impromptu">Impromptu</a> with ajax to pull in content.  I myself far more pull in json to build my content for Impromptu.  So I figured I&#8217;d kill two birds with one stone by creating an example of using Ajax to pull in JSON content, then build a select statement with that data.  Here is the example JSON (nothing tricky here):</p><pre><code class="js">
[
	{ name: 'foo 1', value: 1 },
	{ name: 'foo 2', value: 2 },
	{ name: 'foo 3', value: 3 },
	{ name: 'foo 4', value: 4 },
	{ name: 'foo 5', value: 5 },
	{ name: 'foo 6', value: 6 },
	{ name: 'foo 7', value: 7 },
	{ name: 'foo 8', value: 8 },
	{ name: 'foo 9', value: 9 },
	{ name: 'foo 10', value: 10 },
	{ name: 'foo 11', value: 11 },
	{ name: 'foo 12', value: 12 }
]
</code></pre><p>This should be fairly explanatory, name will be the visible text for each select option, and value will of course be that option&#8217;s value.  To do this we first need to use jQuery&#8217;s $.getJSON() method to pull in the JSON, then within that callback we&#8217;ll build our string and call the $.prompt.  Here is what it looks like:</p><pre><code class="js">
$.getJSON(&#39;demoajax.js&#39;,function(json){

	var str = &#39;Test with a select populated by json data:&lt;br /&gt;&#39;+
		&#39;&lt;select name=&quot;myfield&quot; id=&quot;myfield&quot;&gt;&#39;;

	$.each(json,function(i,obj){
		str += &#39;&lt;option value=&quot;&#39;+ obj.value +&#39;&quot;&gt;&#39;+ obj.name +&#39;&lt;/option&gt;&#39;;
	});
	str += &#39;&lt;/select&gt;&#39;;

	$.prompt(str,{
		callback: function(v,m,f){ //just print out the selection
			$.prompt(&#39;You chose value &#39;+ f.myfield);
		}
	});
});

</code></pre><p>Thats all there is to it.  Here is the <a
href="http://trentrichardson.com/Impromptu/demos/demoajax.html">full working example</a>.  Don&#8217;t forget if you want to do real fun JSON parsing to check out my <a
href="http://trentrichardson.com/jsonsql/" title="jsonSQL">jsonSQL</a> tool to write sql-like statements to parse your JSON to make combo drop downs more fun!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2009/02/24/new-impromptu-and-demo/' rel='bookmark' title='New Impromptu and Demo'>New Impromptu and Demo</a></li><li><a
href='http://trentrichardson.com/2008/11/25/impromptu-an-ajax-form-framework/' rel='bookmark' title='Impromptu: An Ajax Form Framework'>Impromptu: An Ajax Form Framework</a></li><li><a
href='http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/' rel='bookmark' title='Introducing JsonSQL 0.1'>Introducing JsonSQL 0.1</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Incorporating Regex into ORM&#8217;s and Database Abstractions</title><link>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/</link> <comments>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/#comments</comments> <pubDate>Wed, 22 Oct 2008 01:01:19 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Database]]></category> <category><![CDATA[JsonSQL]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[orm]]></category> <category><![CDATA[regex]]></category> <category><![CDATA[regular expressions]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=139</guid> <description><![CDATA[Almost on a daily basis I come across using regular expressions rather convenient. I first toyed with regular expressions in my Compiler Design classes during my undergrad studies, and little did I know they can be used for everyday things like submitting forms. I&#8217;ve even toyed with them to create my own json parser using [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://trentrichardson.com/wp-content/uploads/2008/10/regexp_orm-300x60.jpg" alt="" title="Regexp + ORM" width="300" height="60" align="right" class="alignright size-medium wp-image-140" /><p>Almost on a daily basis I come across using regular expressions rather convenient.  I first toyed with regular expressions in my Compiler Design classes during my undergrad studies, and little did I know they can be used for everyday things like submitting forms.  I&#8217;ve even toyed with them to create my own <a
href="http://trentrichardson.com/jsonsql/">json parser using an SQL like syntax</a>.  I think they&#8217;re a great way to perform strict validation and searching among other things.  Searching.  There is something I need to work on.  Not just strings, but database searches for account numbers, phone numbers, etc.  Not just &#8216;%some string%&#8217;. <a
href="http://trentrichardson.com/2007/12/27/are-you-using-regular-expressions-within-sql/">Regular Expressions within SQL</a> is something I have blogged about before.  I&#8217;ve come to find that Regular Expression support is far from constant and in some cases not even supported(SQLite).</p><p>Incase you&#8217;re curious what I&#8217;m talking about, some database engines allow you to write something like the following:</p><p><code
class="mysql"><br
/> SELECT zip FROM zipcode WHERE REGEXP_LIKE(zip, '[^[:digit:]]’)<br
/> </code></p><p>Sure, this process probably isn&#8217;t very efficient, but it can be very powerful.</p><p>More and more frameworks are moving towards ORM&#8217;s.  You no longer have to write database specific code as the database layer will handle the specifics for you, but none that I am aware of will handle anything of this complexity and for obvious reason.  Lets step back to a simpler solution that many of us deal with on a daily basis:</p><p><code
class="javascript"><br
/> $("input[name$='letter']")<br
/> </code></p><p>jQuery somewhat creates it&#8217;s own language.  It&#8217;s not xpath, its somewhat CSS selectors(ok, mostly css selectors), but there&#8217;s much more added to it&#8217;s own engine.  Perhaps this approach could be a simple solution to the problem.  Support a simplified subset or maybe my own mini language, and use the driver specific code to handle generating the database specific Regular Expressions.  Here&#8217;s what such example may resemble in pseudo code:</p><p><code
class="php"><br
/> $db->select('mytable')->where_regex("acct", "^\d{4}\-\d{8}$");<br
/> </code></p><p>This code might search mytable for the acct that matches a pattern like &#8220;1234-12345678&#8243;.  This isn&#8217;t terribly complex, however will suffice for the majority of everyday needs.  Only supporting this level of complexity is more within the reach creating such if possible.  This is my first post among others to come as this is mostly a brainstorm at this point.  I openly welcome any pointers, advice, resources, or any other comments!</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/10/23/exploring-various-sql-regex-syntax/' rel='bookmark' title='Exploring Various SQL RegEx Syntax'>Exploring Various SQL RegEx Syntax</a></li><li><a
href='http://trentrichardson.com/2010/02/24/select-substring-using-regex-in-postgresql/' rel='bookmark' title='Select Substring Using RegEx in PostgreSQL'>Select Substring Using RegEx in PostgreSQL</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2008/10/21/incorporating-regex-into-orms-and-database-abstractions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>JsonSQL Ported to PHP</title><link>http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/</link> <comments>http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/#comments</comments> <pubDate>Thu, 22 May 2008 16:05:53 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[Javascript]]></category> <category><![CDATA[JsonSQL]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=96</guid> <description><![CDATA[Thanks to Harry over at Code Bus we now have a PHP version of JsonSQL. For those not familiar with JsonSQL, it allows you to use basic SQL syntax to parse json. Supported syntax includes selects, order by, where, and limit and allows you to apply conditions on objects of any depth within the json [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/' rel='bookmark' title='Introducing JsonSQL 0.1'>Introducing JsonSQL 0.1</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/' rel='bookmark' title='New Demo &#8211; Impromptu with Ajax'>New Demo &#8211; Impromptu with Ajax</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Thanks to Harry over at <a
href="http://codeb.us/">Code Bus</a> we now have a <a
href="http://codeb.us/manipulating-php-arrays-with-sql">PHP version of JsonSQL</a>.  For those not familiar with <a
href="http://www.trentrichardson.com/jsonsql/">JsonSQL</a>, it allows you to use basic SQL syntax to parse json.  Supported syntax includes selects, order by, where, and limit and allows you to apply conditions on objects of any depth within the json or array and return an array of the objects selected.  Where clauses are not sql conditions, but conditions from Javascript(or PHP in this conversion), so you have full access to that language&#8217;s functions.</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/' rel='bookmark' title='Introducing JsonSQL 0.1'>Introducing JsonSQL 0.1</a></li><li><a
href='http://trentrichardson.com/2010/01/31/cakephp-postgresql-and-regex/' rel='bookmark' title='CakePHP, PostgreSQL, and Regex'>CakePHP, PostgreSQL, and Regex</a></li><li><a
href='http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/' rel='bookmark' title='New Demo &#8211; Impromptu with Ajax'>New Demo &#8211; Impromptu with Ajax</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Introducing JsonSQL 0.1</title><link>http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/</link> <comments>http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/#comments</comments> <pubDate>Sun, 30 Dec 2007 19:34:49 +0000</pubDate> <dc:creator>trent</dc:creator> <category><![CDATA[JsonSQL]]></category><guid
isPermaLink="false">http://trentrichardson.com/?p=46</guid> <description><![CDATA[After a bit of work it is now possible to use sql to parse json using javascript!. I introduce to you version 0.1 of JsonSQL. Given a javascript object you can write a simple select statement to filter, order and limit the object: jsonsql.query("select title,url from json.channel.items where (category=='javascript' &#124;&#124; category=='vista') order by title,category asc [...]
Related posts:<ol><li><a
href='http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/' rel='bookmark' title='JsonSQL Ported to PHP'>JsonSQL Ported to PHP</a></li><li><a
href='http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/' rel='bookmark' title='New Demo &#8211; Impromptu with Ajax'>New Demo &#8211; Impromptu with Ajax</a></li><li><a
href='http://trentrichardson.com/2007/12/20/javascript-json-parsing-with-sql/' rel='bookmark' title='Javascript JSON Parsing with SQL'>Javascript JSON Parsing with SQL</a></li></ol>]]></description> <content:encoded><![CDATA[<p>After a bit of work it is now possible to use sql to parse json using javascript!.  I introduce to you version 0.1 of <a
target="_blank" title="JsonSQL" href="http://www.trentrichardson.com/jsonsql/">JsonSQL</a>.  Given a javascript object you can write a simple select statement to filter, order and limit the object:</p><p><code
class="javascript"> jsonsql.query("select title,url from json.channel.items<br
/> where (category=='javascript' || category=='vista')<br
/> order by title,category asc limit 3",json);</code></p><p>Give it a shot.  It would be nice to expand this a little more with a few aggregate functions (distinct, count, etc..).</p><p>Related posts:<ol><li><a
href='http://trentrichardson.com/2008/05/22/jsonsql-ported-to-php/' rel='bookmark' title='JsonSQL Ported to PHP'>JsonSQL Ported to PHP</a></li><li><a
href='http://trentrichardson.com/2009/03/03/new-demo-impromptu-with-ajax/' rel='bookmark' title='New Demo &#8211; Impromptu with Ajax'>New Demo &#8211; Impromptu with Ajax</a></li><li><a
href='http://trentrichardson.com/2007/12/20/javascript-json-parsing-with-sql/' rel='bookmark' title='Javascript JSON Parsing with SQL'>Javascript JSON Parsing with SQL</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://trentrichardson.com/2007/12/30/introducing-jsonsql-01/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/52 queries in 0.034 seconds using disk: basic
Object Caching 1227/1274 objects using disk: basic

Served from: trentrichardson.com @ 2012-02-03 22:26:35 -->
