<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>json &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/json/</link>
	<description>Feed of posts on WordPress.com tagged "json"</description>
	<pubDate>Tue, 01 Dec 2009 11:57:59 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[returning json with pylons]]></title>
<link>http://selunedev.wordpress.com/2009/12/01/returning-json-with-pylons/</link>
<pubDate>Mon, 30 Nov 2009 23:54:23 +0000</pubDate>
<dc:creator>selunedev</dc:creator>
<guid>http://selunedev.wordpress.com/2009/12/01/returning-json-with-pylons/</guid>
<description><![CDATA[The pylons web framework offers a nice decorator to return json code from a python dictionnary. In y]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The <a href="http://pylonshq.com">pylons</a> web framework offers a nice decorator to return json code from a python dictionnary. In your pylons controller, this is as simple as :</p>
<pre class="brush: python;">

@jsonify

def do_something(self):

mydict = {name:&#34;foo&#34;}

return mydict
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Calling the Twitter API with jQuery]]></title>
<link>http://bagofspanners.wordpress.com/2009/11/29/calling-the-twitter-api-with-jquery/</link>
<pubDate>Sun, 29 Nov 2009 14:09:54 +0000</pubDate>
<dc:creator>Jonathan</dc:creator>
<guid>http://bagofspanners.wordpress.com/2009/11/29/calling-the-twitter-api-with-jquery/</guid>
<description><![CDATA[Nobody seems to have written this up succinctly, so I am doing so. Here&#8217;s an quick example of ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Nobody seems to have written this up succinctly, so I am doing so. Here&#8217;s an quick example of how you would call the Twitter API with jQuery, and return some results. I also illustrate the basic javascript to iterate through an object&#8217;s collection of properties (<em>something else nobody ever seems to explain</em>).</p>
<h3>Create several files&#8230;</h3>
<ol>
<li>Create &#8220;twitter.htm&#8221; &#8211; this will be your webpage. You can open it locally &#8211; it will still work.</li>
<li>Create &#8220;twitter.js&#8221; &#8211; this will be your javascript file.</li>
<li>Create &#8220;twitter.css&#8221; &#8211; this will be your stylesheet.</li>
<li><a href="http://docs.jquery.com/Downloading_jQuery#Download_jQuery">Download jQuery</a> from it&#8217;s homepage and copy alongside the other files.</li>
</ol>
<h3>Contents of the Files</h3>
<p>Here&#8217;s what needs to be in each file. If you&#8217;re wondering why this example is being done in so many files, it&#8217;s because <em>this is how you SHOULD do it</em> &#8211; I get fed up with seeing examples on the web where code is tacked together in one big file, which encourages bad practice among those learning from it. Also, you&#8217;ll notice I&#8217;m not messing around with the output &#8211; just doing the bare minimum to present the results. This is by design too.</p>
<h3>twitter.htm</h3>
<p><code>
<pre>&#60;html&#62;
&#60;head&#62;
	&#60;title&#62;Twitter Test&#60;/title&#62;
	&#60;script src="jquery-1.3.2.min.js"&#62;&#60;/script&#62;
	&#60;script src="twitter.js" language="javascript"&#62;&#60;/script&#62;
	&#60;link rel="stylesheet" href="twitter.css" /&#62;
&#60;/head&#62;
&#60;body&#62;

&#60;h1&#62;Twitter Test&#60;/h1&#62;

&#60;div id="twitter"&#62;&#60;/div&#62;

&#60;/body&#62;
&#60;/html&#62;</pre>
<p></code></p>
<h3>twitter.js</h3>
<p><code>
<pre>function search_tweets_callback(data){
	if (data.results){
		for(var i=0; i&#60;data.results.length;i++){
			$("#twitter").append("&#60;ul&#62;");
			for (var j in data.results[i]){
				$("#twitter").append("&#60;li&#62;" + j + " = " + data.results[i][j] + "&#60;/li&#62;");
			}
			$("#twitter").append("&#60;/ul&#62;");
		}
	}
}

function search_tweets(term){
	$.getJSON("http://search.twitter.com/search.json?q=" + term + "&#38;callback=?",{}, search_tweets_callback);
	$("#twitter").append("&#60;li&#62;Called Twitter...&#60;/li&#62;");
}

function init(){
	search_tweets("jonbeckett");
}

$(document).ready(function() {
	init();
});</pre>
<p></code></p>
<h3>twitter.css</h3>
<p><code>
<pre>BODY {
	font-family:Georgia;
}</pre>
<p></code></p>
<p><em>Reminder &#8211; remember to copy the jQuery javascript file into the same directory as the above files, or nothing will work.</em></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[My Twitter Flickr Mashup]]></title>
<link>http://lbarclay.wordpress.com/2009/11/26/my-twitter-flickr-mashup/</link>
<pubDate>Thu, 26 Nov 2009 23:20:02 +0000</pubDate>
<dc:creator>lbarclay</dc:creator>
<guid>http://lbarclay.wordpress.com/2009/11/26/my-twitter-flickr-mashup/</guid>
<description><![CDATA[I attended full frontal last week, which was excellent. It gave me inspiration to experiment a bit w]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I attended <a title="Full frontal 09 - Javascript conference" href="http://2009.full-frontal.org/" target="_blank">full frontal</a> last week, which was excellent. It gave me inspiration to experiment a bit with some JavaScript.</p>
<p>I went about setting myself a very loose brief; Completely written in JS, I wanted to do something quick, in no more than seven hours, I didn&#8217;t want to have to write any server-side code and wanted the code to reside on a single page.</p>
<p>I went about looking into the <a title="twitter api" href="http://apiwiki.twitter.com/" target="_blank">Twitter</a> and <a title="flickr API" href="http://www.flickr.com/services/api/" target="_blank">Flickr API</a>s and decided to combine them by doing a photo search on Flickr using tweets from the <a title="Twitter" href="http://www.twitter.com" target="_blank">Twitter</a> public timeline every 60 seconds.</p>
<p>What I came up with ended up as a kind of <a title="Visual social commentary using flickr and twitter" href="http://flittr.lewisbarclay.com" target="_blank">visual social commentary using Twitter and Flickr</a>.</p>
<p style="text-align:left;">
<div id="attachment_219" class="wp-caption aligncenter" style="width: 310px"><a title="Visual social commentary using flickr and twitter" href="http://flittr.lewisbarclay.com" target="_blank"><img class="size-medium wp-image-219" title="flittr" src="http://lbarclay.wordpress.com/files/2009/11/flittr.jpg?w=300" alt="flittr" width="300" height="224" /></a><p class="wp-caption-text">visual social commentary</p></div>
<p style="text-align:left;">I can&#8217;t claim any credit for any of the content and I doubt that the idea is unique or original but  I did set out some rules for getting the content : search terms had to exceed two words and I attempted to recognise proper nouns and only use them. The content updated every minute. The tweets must not be recognised replies.</p>
<p style="text-align:left;">The result gave some interesting effects on me as a viewer. The search result images weren&#8217;t always obvious results from the tweets, hey &#8211; people tag their photos with strange tags. So knowing that I only had 60 seconds to look through the tweets (not always in English) it made trying to figure out the relationship of the narrative with the  corresponding photos more important, somehow and it became more important to look at the photos and see where the connections came from when I got frustrated.</p>
<p style="text-align:left;">I also liked the fact that very few users would see the same page with the same tweets and images. This makes me want to expand on the idea and add the option to &#8217;save your favourite fleet&#8217; (a fleet is what I called the combination of tweet a Flickr images, brilliant hey!)<br />
I thought about adding the option to enter a twitter screen name and allow that to work in the same way on a specific timeline.</p>
<p style="text-align:left;">
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex &amp; PHP - Transmitting data using JSON]]></title>
<link>http://sadhas.wordpress.com/2009/11/26/flex-php-transmitting-data-using-json/</link>
<pubDate>Thu, 26 Nov 2009 12:40:47 +0000</pubDate>
<dc:creator>Sathasivam</dc:creator>
<guid>http://sadhas.wordpress.com/2009/11/26/flex-php-transmitting-data-using-json/</guid>
<description><![CDATA[In almost every RIA data needs to be transmitted from a server to the client. Now there are many way]]></description>
<content:encoded><![CDATA[In almost every RIA data needs to be transmitted from a server to the client. Now there are many way]]></content:encoded>
</item>
<item>
<title><![CDATA[New Demo site]]></title>
<link>http://vishistory.wordpress.com/2009/11/26/new-demo-site/</link>
<pubDate>Thu, 26 Nov 2009 09:55:08 +0000</pubDate>
<dc:creator>vishistory</dc:creator>
<guid>http://vishistory.wordpress.com/2009/11/26/new-demo-site/</guid>
<description><![CDATA[The new demo site with an example of the type of project information that can be easily built up is ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The new demo site with an example of the type of project information that can be easily built up is available to see at <a href="http://79.170.43.15/visualhistory.org.uk/googlemaps/jqmap/click-and-pop.html">http://79.170.43.15/visualhistory.org.uk/googlemaps/jqmap/click-and-pop.html</a>  .  The visual with markers is shown in the first image.  </p>
<p>By clicking on the markers a pop-up screen appears with limited detail (including a thumbnail image) of the point that is being illustrated.  This links to more detail in a separate web page opened in a new window.</p>
<div class="mceTemp">
<dl class="wp-caption alignnone">
<dt class="wp-caption-dt"><a href="http://vishistory.wordpress.com/files/2009/11/rush1j.jpg"><br />
<img class="size-full wp-image-33" title="rush1j" src="http://vishistory.wordpress.com/files/2009/11/rush1j.jpg" alt="Demo project image" width="200" height="147" /></a></dt>
<dd class="wp-caption-dd">Rushmore project</dd>
</dl>
<p><a href="http://vishistory.wordpress.com/files/2009/11/rush2j1.jpg"><img class=" size-full wp-image-37" title="rush2j" src="http://vishistory.wordpress.com/files/2009/11/rush2j1.jpg" alt="rush2j" width="200" height="147" /></a> Work is continuing to develop an editor to enable background and markers to be uploaded, dragging the markers into place and editing the pop-up windows.  Afew comments on technical standards: jquery has been a great help in this project and particularly the <a href="http://docs.jquery.com/UI">jquery ui </a>with its draggable() function.  Also we decided to go down the route of using JSON to hold the data for the display which means the entire display can be viewed without a server &#8211; and even off-line so long as the data file, images and jquery libraries are packaged together.  This makes it a great tool to display student portfolios of work.</p>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Pulling Google Spreadsheets data to Projectrix]]></title>
<link>http://research2009.wordpress.com/2009/11/25/pulling-google-spreadsheets-data-to-projectrix/</link>
<pubDate>Wed, 25 Nov 2009 16:16:40 +0000</pubDate>
<dc:creator>falloutkee</dc:creator>
<guid>http://research2009.wordpress.com/2009/11/25/pulling-google-spreadsheets-data-to-projectrix/</guid>
<description><![CDATA[I&#8217;ve been searching for existing implementations for this until I encountered David Burger]]></description>
<content:encoded><![CDATA[I&#8217;ve been searching for existing implementations for this until I encountered David Burger]]></content:encoded>
</item>
<item>
<title><![CDATA[jLinq Update (2.2.1)]]></title>
<link>http://somewebguy.wordpress.com/2009/11/23/jlinq-update-2-2-1/</link>
<pubDate>Tue, 24 Nov 2009 02:03:46 +0000</pubDate>
<dc:creator>webdev_hb</dc:creator>
<guid>http://somewebguy.wordpress.com/2009/11/23/jlinq-update-2-2-1/</guid>
<description><![CDATA[I&#8217;m off from work this week so the first thing I did was get some work done on jLinq. I&#8217;]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m off from work this week so the first thing I did was get some work done on jLinq. I&#8217;ve had a few bugs I&#8217;ve needed to sort out along with a new feature I wanted to implement. I&#8217;m also going to be working on documentation this week. Previously, I had created a Wiki and was hoping that people might add to the documentation&#8230; but instead spam bots pretty much ruined it so I&#8217;ll be starting over from scratch&#8230; oh well..</p>
<h3>New Features</h3>
<p>jLinq itself doesn&#8217;t really have a new feature but instead a new way to get the jLinq library. Instead of simply downloading a standard jLinq library you can use the new <a href="http://hugoware.net/Projects/jLinq/FrameworkGenerator" target="_blank">online jLinq Framework Generator to select only the functionality that you want to include.</a> You can still download the basic pack but this option gives you a little more control what goes into your version of jLinq.</p>
<p><a href="http://somewebguy.wordpress.com/files/2009/11/framework-generator.jpg"><img src="http://somewebguy.wordpress.com/files/2009/11/framework-generator.jpg?w=300" alt="" title="framework-generator" width="300" height="252" class="aligncenter size-medium wp-image-859" /></a></p>
<h3>Changes</h3>
<p>The most notable change for jLinq is that all of the operator commands have been included as standard functions for the framework. Before, these functions were actually methods extended onto the framework. Since these functions are required for jLinq to work I&#8217;ve moved them so that they are in every jLinq framework by default.</p>
<h3>Bug Fixes</h3>
<p><strong>orderBy with joined records would return incorrect results</strong><br />
jLinq uses <code>eval</code> to figure out the values of field names since you can provide methods, array indexes or whatever. The code used to sort the values wasn&#8217;t getting the values correctly so the sorted result was always wrong.</p>
<p><strong>using 0 in certain comparisons would return incorrect results</strong><br />
Ah, this one was fun. So check out the code below&#8230;<br />
<code><br />
var values = [ 0 ];<br />
var index = 0;<br />
var a = !values[index];<br />
var b = values[index] == null;<br />
</code></p>
<p>So what is <strong>a</strong> and what is <strong>b</strong>? If you said <strong>true</strong> and <strong>false</strong> then give yourself a cookie.</p>
<p>jLinq uses the number of arguments passed to help determine if anything is being memorized (like the field name). jLinq makes a quick pass to select all values until it finds a null value&#8230; or at least that is what I meant for it to do. Unfortunately, I wasn&#8217;t thinking when I wrote that method and didn&#8217;t check explicitly for <code>null</code>.</p>
<h3>Feedback</h3>
<p>If you find any problems with jLinq or have any suggestions, please leave a comment or <a href="http://hugoware.net/contact" target="_blank">contact me directly</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[REST based message queue]]></title>
<link>http://zenmachine.wordpress.com/2009/11/22/rest-based-message-queue/</link>
<pubDate>Sun, 22 Nov 2009 14:10:38 +0000</pubDate>
<dc:creator>gm</dc:creator>
<guid>http://zenmachine.wordpress.com/2009/11/22/rest-based-message-queue/</guid>
<description><![CDATA[I&#8217;ve been playing with lots of message queues lately, and with each of one, a protocol is favo]]></description>
<content:encoded><![CDATA[I&#8217;ve been playing with lots of message queues lately, and with each of one, a protocol is favo]]></content:encoded>
</item>
<item>
<title><![CDATA[Groovy – Producing JSON using Groovlet and JSONObject]]></title>
<link>http://companyranjan.wordpress.com/2009/11/19/groovy-%e2%80%93-producing-json-using-groovlet-and-jsonobject-4/</link>
<pubDate>Thu, 19 Nov 2009 08:00:13 +0000</pubDate>
<dc:creator>ranjan</dc:creator>
<guid>http://companyranjan.wordpress.com/2009/11/19/groovy-%e2%80%93-producing-json-using-groovlet-and-jsonobject-4/</guid>
<description><![CDATA[Groovy &ndash; Producing JSON using Groovlet and JSONObject All right I admit I like groovy, because]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div>
<p style="margin-bottom:0;text-align:center;"> <font size="4"><u><b>Groovy &#8211; Producing JSON using Groovlet and JSONObject</b></u></font> </p>
<p style="margin-bottom:0;text-align:center;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">All right I admit I like groovy, because it&#8217;s gives you taste of best of both worlds &#8211; all the dynamism of Python and Ruby and still be close to Java.</font> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">I was trying to create simple JSON output using Groovlets and JSONObject and this is what I came up with.</font> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">In order to use Groovlets use the  <a href="http://www.ibm.com/developerworks/java/library/j-pg03155/">this link</a> to set it up in your favorite IDE.</font> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">And then</font> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> </p>
<ol>
<li>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">Create index.groovy in WEB Folder.</font></p>
</li>
<li>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">Download the source code from  <a href="http://json.org/java">json.org/java</a> site</font></p>
</li>
<li>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">put in your src folder of web project.</font></p>
</li>
<li>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">In your index.groovy put in this code</font></p>
</li>
</ol>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> </p>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> <font size="3">Here&#8217;s the code</font> </p>
<pre style="margin-left:.49in;font-weight:normal;text-align:left;text-decoration:none;">
<font size="3">import org.json.*</font>
import com.ranjan.*;

/***************************************************
*
*       Setting up response content type is important
*       and in best practice.
****************************************************/

response.setContentType("application/json");

def fromMap =
[name:"Frederic Jean",age:32] as JSONObject
def fromList =
["English","French","Spanish"] as JSONArray

def newMap =
[
    world:[
        countries:[
            india:[
                cities:["delhi", "bombay"]
            ],
            america:[
                states:["new york", "chicago"]
            ],
            japan:[
                states:["tokyo","some great japanese city"]
            ]

        ]
    ]
] as JSONObject     // this is what does the trick

// prints the json map
println newMap

The result...
<img border="0" height="160"/>

</pre>
<p style="margin-bottom:0;font-weight:normal;text-decoration:none;text-align:left;"> </p>
<p></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[PHP e Javascript para quem não conhece]]></title>
<link>http://phpedinei.wordpress.com/2009/11/16/php-e-javascript-para-quem-nao-conhece/</link>
<pubDate>Mon, 16 Nov 2009 17:31:32 +0000</pubDate>
<dc:creator>phpedinei</dc:creator>
<guid>http://phpedinei.wordpress.com/2009/11/16/php-e-javascript-para-quem-nao-conhece/</guid>
<description><![CDATA[Bom, meu trabalho na disciplina de Teoria a Informática falei sobre PHP e Javascript para quem não c]]></description>
<content:encoded><![CDATA[Bom, meu trabalho na disciplina de Teoria a Informática falei sobre PHP e Javascript para quem não c]]></content:encoded>
</item>
<item>
<title><![CDATA[JSON Tutorial - Displaying Friendfeed items]]></title>
<link>http://googleclosuretutorials.wordpress.com/2009/11/14/json-tutorial-displaying-friendfeed-items/</link>
<pubDate>Sat, 14 Nov 2009 16:08:27 +0000</pubDate>
<dc:creator>googleclosuretutorials</dc:creator>
<guid>http://googleclosuretutorials.wordpress.com/2009/11/14/json-tutorial-displaying-friendfeed-items/</guid>
<description><![CDATA[There&#8217;s an interesting tutorial at lahosken.san-francisco.ca.us for retrieving and displaying ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>There&#8217;s an interesting tutorial at lahosken.san-francisco.ca.us for <a href="http://lahosken.san-francisco.ca.us/frivolity/prog/closure_ffdemo/">retrieving and displaying Friendfeed items using Google Closure&#8217;s Jsonp class</a>. It&#8217;s great for seeing how to handle JSON requests with Closure, as well as covering some useful methods in goog.array and a number of DOM manipulation methods in goog.dom.<br />
Well worth running through.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JBind vs JTemplate]]></title>
<link>http://donji.wordpress.com/2009/11/14/jbind-vs-jtemplate/</link>
<pubDate>Sat, 14 Nov 2009 01:34:38 +0000</pubDate>
<dc:creator>donji</dc:creator>
<guid>http://donji.wordpress.com/2009/11/14/jbind-vs-jtemplate/</guid>
<description><![CDATA[A few days ago, when we sending the requirement to a third part software development company, we spe]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>A few days ago, when we sending the requirement to a third part software development company, we specified that we want to use JBind.</p>
<p>They come back with a response that they suggest JTemplate.   From a design prospective, JBind is definately better.   Although there are spaces to improve.    The conditional processing power of JTemplate is not really needed.  Because we got the Json data, it&#8217;s very easy to preprocess Json data before the binding. Besides, JBind have the function of actions can be used.</p>
<p>However, the developer of the 3rd party company is claiming that the JBind is slow and sometime freeze browser&#8230;. While we&#8217;ve asked them to send the pages over.  After 3 days, the did not send anything over.  Today they tell us they did extensive research on JBind and they are Ok with it now.  I could not keep me from guessing what was the problem?   After I solved my issue of intercepting and parsing WebMethod parameters, I did some research.  The problem with JBind, is more of a problem with IE.  When IE have comment between select and option tag, it freezes sometimes.  like this:</p>
<p>&#60;select&#62;</p>
<p>&#60;!&#8211;repeat&#8211;&#62;</p>
<p>&#60;option value=1&#62;first&#60;/option&#62;</p>
<p>&#60;option value=2&#62;second&#60;/option&#62;</p>
<p>&#60;!&#8211;repeat&#8211;&#62;</p>
<p>&#60;/select&#62;</p>
<p>The following article in <a href="http://www.elemenex.com/index.php?option=com_content&#38;view=article&#38;id=46:jquery-jbind-and-select-tag-in-ie&#38;catid=6:jquery&#38;Itemid=30">http://www.elemenex.com/index.php?option=com_content&#38;view=article&#38;id=46:jquery-jbind-and-select-tag-in-ie&#38;catid=6:jquery&#38;Itemid=30</a> gives more detail about this.  However, I don&#8217;t quite like this kind of extra work for every place that uses select.</p>
<p>For about 2 hours, I&#8217;ve tried to add a optional parameter to allow me to specify the loop out of the &#60;select&#62;.  While I am almost done and debugging the functionality, I realized that the problem is that the template is defined in html. What if define the template in javascript variable, then JBind should be ok with IE right?  It&#8217;s very easy to try. So, with another 10 minutes, I got it working without modifying JBind. Vola!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Flex and JSON]]></title>
<link>http://calebburch.wordpress.com/2009/11/12/flex-and-json/</link>
<pubDate>Thu, 12 Nov 2009 19:27:10 +0000</pubDate>
<dc:creator>calebburch</dc:creator>
<guid>http://calebburch.wordpress.com/2009/11/12/flex-and-json/</guid>
<description><![CDATA[Today I was working on interfacing an API I wrote recently with an Adobe Flex App.  The API returns ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Today I was working on interfacing an API I wrote recently with an Adobe Flex App.  The API returns some JSON values that are nested, have arrays within them etc.  I was trying to figure out a good way to cast the JSON I was getting back once decoding it using the <a href="http://code.google.com/p/as3corelib/" target="_blank">as3 core library</a>.  After trying to cast it as a class object I had made with the same fields as the JSON objects I realized this wasn&#8217;t going to work as easily as .NET.</p>
<p>I first checked my JSON to make sure it was properly formatted etc&#8230; some good tools to use are:</p>
<p><a href="http://www.jslint.com/" target="_blank">XML to JSON converter<br />
JSON syntax checker</a></p>
<p>I then found out that I was attempting to make this way to complicated and that AS3 allows you to access fields of the class object even if it doesn&#8217;t know they exist.</p>
<p>So the code boils down to something really basic as:</p>
<p class="code">
<code>var jd:JSONDecoder = new JSONDecoder( "{\"source\":{\"id\":\"123\",\"title\":\"cnn article\"}}");<br />
var o = jd.getValue();<br />
var title:String = o.source.title;<br />
var id:String = o.source.id;<br />
</code>
</p>
<p>Using the AS3 library I run the decoder on a string of JSON.  That transfers it into a basic Object class.  The fields are still stored w/in this object class so I can just access them the . notation.  Unfortunately this has no type checking so if you have an error your script will break.  I&#8217;ll be looking in the future for type casting but this is good for now.</p>
<p>A slightly more complex example that adds the files to a list component:</p>
<p>JSON:<br />
{<br />
&#8220;articles&#8221;:<br />
{<br />
&#8220;article&#8221;:<br />
[<br />
{<br />
"id": "386",<br />
"description": "Kabul",<br />
"pub_date": "10/25/2009 11:42:22 PM",<br />
"title": "can open source lead to open government? media review of WhiteHouse.gov going Drupal http://is.gd/4Budj by @lauras",<br />
"url": "http://twitter.com/ericg/statuses/5159153866"<br />
},<br />
{<br />
"id": "387",<br />
"description": "Kabul, Afghanistan",<br />
"pub_date": "10/25/2009 4:06:55 AM",<br />
"title": "Pakistan arrests Afghan imams and asks them to fight against the Afghan government",<br />
"url": "http://twitter.com/Hairan/statuses/5139728367"<br />
}]<br />
}<br />
}</p>
<p>Code:</p>
<p class="code">
<code>var jd:JSONDecoder = new JSONDecoder(jsonData);<br />
var test = jd.getValue();<br />
var arr:Array = test.feeds.feed;<br />
for each ( var o:Object in arr )<br />
{<br />
     o.label = o.title;<br />
     listData.addItem(o);<br />
}<br />
</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[SOAP vs. JSON-RPC vs. ?]]></title>
<link>http://sitesandsounds.wordpress.com/2009/11/10/soap-vs-json-rpc-vs/</link>
<pubDate>Tue, 10 Nov 2009 19:48:39 +0000</pubDate>
<dc:creator>sitesandsounds</dc:creator>
<guid>http://sitesandsounds.wordpress.com/2009/11/10/soap-vs-json-rpc-vs/</guid>
<description><![CDATA[I&#8217;ve been looking into a web services tool that would best suit what I&#8217;m aiming to do, u]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;ve been looking into a web services tool that would best suit what I&#8217;m aiming to do, updating data in real-time and messaging. I&#8217;m leaning toward jQuery and JSON since I&#8217;ve used that a bit in the past and find it easy and lightweight. However, looking into</p>
<p><a title="Soap Jr" href="http://soapjr.org/">Soap JR</a> I may go that route as well. I appreciate your thoughts. I haven&#8217;t actually used SOAP (in the past I wrote some basic socket servers that would perform messaging for me in C/C++, so I never needed SOAP )  but I&#8217;ve read and heard that it&#8217;s bloated and slow (not what I&#8217;m looking for).  I&#8217;ll post a demo of using JSON soon and also a SOAP JR demo if I should go that route.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSON]]></title>
<link>http://dbglory.wordpress.com/2009/11/10/json/</link>
<pubDate>Tue, 10 Nov 2009 12:10:13 +0000</pubDate>
<dc:creator>dbglory</dc:creator>
<guid>http://dbglory.wordpress.com/2009/11/10/json/</guid>
<description><![CDATA[JSON (JavaScript Object Noattion) là 1 định dạng hoán vị dữ liệu nhanh. Chúng dễ dàng cho chúng ta đ]]></description>
<content:encoded><![CDATA[JSON (JavaScript Object Noattion) là 1 định dạng hoán vị dữ liệu nhanh. Chúng dễ dàng cho chúng ta đ]]></content:encoded>
</item>
<item>
<title><![CDATA[Convert XML to JSON string.]]></title>
<link>http://trungpv.wordpress.com/2009/11/10/convert-xml-to-json-string/</link>
<pubDate>Tue, 10 Nov 2009 02:17:21 +0000</pubDate>
<dc:creator>trungpv</dc:creator>
<guid>http://trungpv.wordpress.com/2009/11/10/convert-xml-to-json-string/</guid>
<description><![CDATA[Have you ever think how to convert XML data to JSON string, the next is JSON string to objects, and ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Have you ever think how to convert XML data to JSON string, the next is JSON string to objects, and you can easily navigate to the XML data by access to object’s properties.</p>
<p>The following code show you a way to convert XML data to JSON string: </p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:83.85%;font-family:'Courier New', courier, monospace;direction:ltr;height:311px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">string</span> XmlToJSON(XmlDocument xmlDoc)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           StringBuilder sbJSON = <span style="color:#0000ff;">new</span> StringBuilder();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Append(<span style="color:#006080;">"{ "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           XmlToJSONnode(sbJSON, xmlDoc.DocumentElement, <span style="color:#0000ff;">true</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Append(<span style="color:#006080;">"}"</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">return</span> sbJSON.ToString();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#008000;">//  XmlToJSONnode:  Output an XmlElement, possibly as part of a higher array</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> XmlToJSONnode(StringBuilder sbJSON, XmlElement node, <span style="color:#0000ff;">bool</span> showNodeName)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">if</span> (showNodeName)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               sbJSON.Append(<span style="color:#006080;">"\""</span> + SafeJSON(node.Name) + <span style="color:#006080;">"\": "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Append(<span style="color:#006080;">"{"</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">// Build a sorted list of key-value pairs</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">//  where   key is case-sensitive nodeName</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">//          value is an ArrayList of string or XmlElement</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">//  so that we know whether the nodeName is an array or not.</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           SortedList childNodeNames = <span style="color:#0000ff;">new</span> SortedList();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">//  Add in all node attributes</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">if</span> (node.Attributes != <span style="color:#0000ff;">null</span>)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">foreach</span> (XmlAttribute attr <span style="color:#0000ff;">in</span> node.Attributes)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   StoreChildNode(childNodeNames, attr.Name, attr.InnerText);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">//  Add in all nodes</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">foreach</span> (XmlNode cnode <span style="color:#0000ff;">in</span> node.ChildNodes)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (cnode <span style="color:#0000ff;">is</span> XmlText)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   StoreChildNode(childNodeNames, <span style="color:#006080;">"value"</span>, cnode.InnerText);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (cnode <span style="color:#0000ff;">is</span> XmlElement)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   StoreChildNode(childNodeNames, cnode.Name, cnode);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">// Now output all stored info</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">foreach</span> (<span style="color:#0000ff;">string</span> childname <span style="color:#0000ff;">in</span> childNodeNames.Keys)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               ArrayList alChild = (ArrayList)childNodeNames[childname];</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (alChild.Count == 1)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   OutputNode(childname, alChild[0], sbJSON, <span style="color:#0000ff;">true</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">else</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbJSON.Append(<span style="color:#006080;">" \""</span> + SafeJSON(childname) + <span style="color:#006080;">"\": [ "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   <span style="color:#0000ff;">foreach</span> (<span style="color:#0000ff;">object</span> Child <span style="color:#0000ff;">in</span> alChild)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                       OutputNode(childname, Child, sbJSON, <span style="color:#0000ff;">false</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbJSON.Remove(sbJSON.Length - 2, 2);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbJSON.Append(<span style="color:#006080;">" ], "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Remove(sbJSON.Length - 2, 2);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Append(<span style="color:#006080;">" }"</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#008000;">//  StoreChildNode: Store data associated with each nodeName</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#008000;">//                  so that we know whether the nodeName is an array or not.</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> StoreChildNode(SortedList childNodeNames, <span style="color:#0000ff;">string</span> nodeName, <span style="color:#0000ff;">object</span> nodeValue)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">// Pre-process contraction of XmlElement-s</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">if</span> (nodeValue <span style="color:#0000ff;">is</span> XmlElement)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#008000;">// Convert  &#60;aa&#62;&#60;/aa&#62; into "aa":null</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#008000;">//          &#60;aa&#62;xx&#60;/aa&#62; into "aa":"xx"</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               XmlNode cnode = (XmlNode)nodeValue;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (cnode.Attributes.Count == 0)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   XmlNodeList children = cnode.ChildNodes;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   <span style="color:#0000ff;">if</span> (children.Count == 0)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                       nodeValue = <span style="color:#0000ff;">null</span>;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (children.Count == 1 &#38;&#38; (children[0] <span style="color:#0000ff;">is</span> XmlText))</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                       nodeValue = ((XmlText)(children[0])).InnerText;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">// Add nodeValue to ArrayList associated with each nodeName</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#008000;">// If nodeName doesn't exist then add it</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">object</span> oValuesAL = childNodeNames[nodeName];</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           ArrayList ValuesAL;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">if</span> (oValuesAL == <span style="color:#0000ff;">null</span>)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               ValuesAL = <span style="color:#0000ff;">new</span> ArrayList();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               childNodeNames[nodeName] = ValuesAL;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">else</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               ValuesAL = (ArrayList)oValuesAL;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           ValuesAL.Add(nodeValue);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> OutputNode(<span style="color:#0000ff;">string</span> childname, <span style="color:#0000ff;">object</span> alChild, StringBuilder sbJSON, <span style="color:#0000ff;">bool</span> showNodeName)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">if</span> (alChild == <span style="color:#0000ff;">null</span>)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (showNodeName)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbJSON.Append(<span style="color:#006080;">"\""</span> + SafeJSON(childname) + <span style="color:#006080;">"\": "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               sbJSON.Append(<span style="color:#006080;">"null"</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (alChild <span style="color:#0000ff;">is</span> <span style="color:#0000ff;">string</span>)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (showNodeName)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbJSON.Append(<span style="color:#006080;">"\""</span> + SafeJSON(childname) + <span style="color:#006080;">"\": "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">string</span> sChild = (<span style="color:#0000ff;">string</span>)alChild;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               sChild = sChild.Trim();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               sbJSON.Append(<span style="color:#006080;">"\""</span> + SafeJSON(sChild) + <span style="color:#006080;">"\""</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">else</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               XmlToJSONnode(sbJSON, (XmlElement)alChild, showNodeName);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           sbJSON.Append(<span style="color:#006080;">", "</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#008000;">// Make a string safe for JSON</span></pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">string</span> SafeJSON(<span style="color:#0000ff;">string</span> sIn)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           StringBuilder sbOut = <span style="color:#0000ff;">new</span> StringBuilder(sIn.Length);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">foreach</span> (<span style="color:#0000ff;">char</span> ch <span style="color:#0000ff;">in</span> sIn)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">if</span> (Char.IsControl(ch) &#124;&#124; ch == <span style="color:#006080;">'\''</span>)</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   <span style="color:#0000ff;">int</span> ich = (<span style="color:#0000ff;">int</span>)ch;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbOut.Append(<span style="color:#006080;">@"\u"</span> + ich.ToString(<span style="color:#006080;">"x4"</span>));</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   <span style="color:#0000ff;">continue</span>;</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               <span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (ch == <span style="color:#006080;">'\"'</span> &#124;&#124; ch == <span style="color:#006080;">'\\' &#124;&#124; ch == '</span>/<span style="color:#006080;">')</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               {</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">                   sbOut.Append('</span>\\');</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">               sbOut.Append(ch);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           }</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">           <span style="color:#0000ff;">return</span> sbOut.ToString();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">       }</pre>
<p><!--CRLF--></div>
</div>
<p>And after this, you can use JSON.NET (<a title="http://www.codeplex.com/Json" href="http://www.codeplex.com/Json">http://www.codeplex.com/Json</a>) or JavaScriptSerializer (System.Web.Script.Serialization of System.Web.Extension dll (.NET 3.5) to de-serialize&#160; to objects</p>
<p>JSON.NET</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:95.94%;font-family:'Courier New', courier, monospace;direction:ltr;height:105px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">XmlDocument doc = <span style="color:#0000ff;">new</span> XmlDocument();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            doc.Load(<span style="color:#006080;">@"C:\owssvr.xml"</span>);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">string</span> jsonString = XmlToJSON(doc);</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            Newtonsoft.Json.Linq.JObject jSonObject = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(jsonString);</pre>
<p><!--CRLF--></div>
</div>
<table border="0" cellspacing="0" cellpadding="2" width="400">
<tbody>
<tr>
<td valign="top" width="400">
<pre class="csharpcode">&#160;</pre>
</td>
</tr>
</tbody>
</table>
<pre class="csharpcode">JavascriptSerializer</pre>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:94.8%;font-family:'Courier New', courier, monospace;direction:ltr;height:61px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">JavaScriptSerializer jss = <span style="color:#0000ff;">new</span> JavaScriptSerializer();</pre>
<p><!--CRLF-->
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:'Courier New', courier, monospace;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">object</span> jSonObject = jss.DeserializeObject(jsonString);</pre>
<p><!--CRLF--></div>
</div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[PHP + JSON]]></title>
<link>http://ainternetenossa.wordpress.com/2009/11/09/php-json/</link>
<pubDate>Mon, 09 Nov 2009 17:44:36 +0000</pubDate>
<dc:creator>Lucas Martins</dc:creator>
<guid>http://ainternetenossa.wordpress.com/2009/11/09/php-json/</guid>
<description><![CDATA[A partir do PHP 5.2.0 temos uma extensão para JSON que facilita o transporte de dados do PHP para o ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://ainternetenossa.wordpress.com/files/2009/11/json-plus-php.png"><img class="alignright size-full wp-image-216" title="PHP + JSON" src="http://ainternetenossa.wordpress.com/files/2009/11/json-plus-php.png" alt="PHP + JSON" width="271" height="92" /></a>A partir do PHP 5.2.0 temos uma extensão para JSON que facilita o transporte de dados do PHP para o JavaScript (via AJAX) e vice-versa.</p>
<p>Com o advento do Ajax, JSON se tornou um formato para intercâmbio de dados bem mais eficiente e compacto que XML. E nada como tratá-lo como um objeto também no lado do servidor, assim como fazemos no JavaScript. As duas funções que tratam da conversão objeto-string e string-objeto no PHP são <code>json_encode</code> e <code>json_decode</code>, respectivamente.</p>
<p>Vou lhes mostrar um exemplo de como trabalhar com PHP + JSON. Primeiramente vamos formatar corretamente o código PHP que será chamado via AJAX no Javascript.</p>
<pre class="brush: php;">
&#60;?php
$produto = array(
	'id' =&#62; 32,
	'nome' =&#62; 'Camera Digital Sony W220',
	'fabricante' =&#62; 'Sony',
	'valor' =&#62; 'R$ 799,00'
);

$produtoJSON = &#34;var produto = &#34; . json_encode($produto);

echo $produtoJSON;
// var produto = {&#34;id&#34;: 32, &#34;nome&#34;: &#34;Camera Digital Sony W220&#34;, &#34;fabricante&#34;: &#34;Sony&#34;, &#34;valor&#34;: &#34;R$ 799,00&#34;}
?&#62;
</pre>
<p>Agora no javascript vamos dar um alerta com os dados separados:</p>
<pre class="brush: jscript;">
&#60;script type=&#34;text/javascript&#34;&#62;

/*
 ... requisição ajax ...
*/

eval(ajax.responseText); // transformo a string do resultado em formato de código válido do javascript

alert(&#34; id = &#34; + produto['id'] + &#34;\n nome = &#34; + unescape(produto['nome']) + &#34;\n fabricante = &#34; + unescape(produto['fabricante']) + &#34;\n valor = &#34; + unescape(produto['valor']));
&#60;/script&#62;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Serialization/Streaming Protocols: What we got?]]></title>
<link>http://notechnique.wordpress.com/2009/11/06/serializationstreaming-protocols-what-we-got/</link>
<pubDate>Fri, 06 Nov 2009 17:40:55 +0000</pubDate>
<dc:creator>Srinivasan</dc:creator>
<guid>http://notechnique.wordpress.com/2009/11/06/serializationstreaming-protocols-what-we-got/</guid>
<description><![CDATA[It&#8217;s takes a huge effort to build a friendly API, and build a community around it. But once yo]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>It&#8217;s takes a huge effort to build a friendly API, and build a community around it. But once you have a popular service API, the next thing is the handling the traffic. It doesn&#8217;t have to be external API, it can be a your web front-end posting requests to the backend service layer.</p>
<p>As the user base explodes, a bit saved is bandwidth and money saved. This applies to mobile clients as well. With things hosted in clouds these days, it does matter how much bandwidth you use and how less resources you consume.</p>
<p>Two things magnifies the problem:</p>
<p>1) User Base &#8211; if the user base is really large then even transferring 1MB per user over wire is going to hit the wall. Imagine 1 million users trying to access your webpage.</p>
<p>2) Amount of data transfer &#8211; if you are transferring huge amount of data, say your website is cloud based storage system or online cloud database, then again it&#8217;s going to hit the wall in performance soon again.</p>
<p>So to move you objects from server to client, you need to see several serialization options. I will start with some standard ones, and list some recents ones that sounds interesting.</p>
<p><a href="http://www.w3.org/XML/" target="_blank">XML</a>:</p>
<p>Human readable, and machine parse-able at the same time. But probably the most verbose serialization option we have. Also the human readable advantage goes down very quickly as the size of the XML file goes up.</p>
<p><a href="http://json.org/" target="_blank">JSON</a>:</p>
<p>JSON (pronounced as Jason), stands for JavaScript Object Notation. Its pretty popular with AJAX, and JavaScript based web libraries. It keeps the data compact, and saves us from verbosity of XML. JSON format supports only text data, and does&#8217;nt have native support for binary data.</p>
<p><a href="http://hessian.caucho.com/doc/" target="_blank">Hessian</a>:</p>
<p>Hessian is been there for a while, and it is quite popular with J2ME world because of the small required dependencies, and efficient binary protocol. Starting from Hessian 1.0 Spec, it has now come to Hessian 2.0. Hessian 2.0 spec seems to be quite comparable with any of the new age/recent protocols that were released.</p>
<p><a href="http://code.google.com/apis/protocolbuffers/docs/overview.html" target="_blank">Protocol Buffers</a>:</p>
<p>Coming from google, we can definitely assume it should have great scalability &#38; performance. It supports both text and binary format. All your text representation will be converted to a binary format before sending it across the wire. You have to first create  a interface file (.proto) describing the fields, and compile them to Java/Any supported language classes. Then you can serialize/deserialize from binary format to Objects in your language. The main drawback is for you to specify the interface and compile them to objects, but having things statically compiled will give you some performance advantages. It does support binary data as well in the message structure.</p>
<p><a href="http://incubator.apache.org/thrift/" target="_blank">Apache Thrift</a>:</p>
<p>Thrift is originally created and used within FaceBook team, and later released as Apache OpenSource project. It pretty much similar to google with define-compile-use cycle. You need to define the message structure using .thrift file, and compile them using thrift compiler, and use them in you services/clients. Apache Thrift has poor documentation when compared to other protocols.</p>
<p><a href="http://hadoop.apache.org/avro/docs/current/" target="_blank">Apache Avro</a>:</p>
<p>This is one of sub-projects of <a href="http://hadoop.apache.org/" target="_blank">Apache Hadoop</a>, a &#8216;Google Map-Reduce&#8217; inspired framework for Java. This project is contributed heavily by Yahoo! and they said to use it extensively for their infrastructure. Avro&#8217;s design goal is as well to support Dynamic Typing; that is be able to exchange information without the compile-use cycle. The schema of the data structure is defined in JSON format, and its exchanged on the initial interaction; and the rest of the transfers client uses the schema to read the data.</p>
<p><a href="http://bert-rpc.org/" target="_blank">BERT &#38; BERT-RPC</a>:</p>
<p>BERT stands for Binary ERlang Term. It is based on the Erlang&#8217;s binary serialization format. The author of this format is founder of the GitHub. The git-hub team posted a article on how they improved the performance of their site using this new protocol. Their main reason for not using Protocol Buffers &#38; Thrift is that you have to go through mundane define-compile-use cycle. Instead they created this protocol which supports dynamic data format definition, so the actual data itself will contain meta-information about the data structure (the client can read them on the go). GitHub being a huge repository of open source projects, and people forking out branches, checking in/checking out huge code bases we can assume the traffic they could be handling; BERT should have been really comparable in-order to be a better alternative compared to Protocol Buffers &#38; Thrift.</p>
<p>Lets see what improvements, and comparison reports could future bring about these protocols.</p>
<p>Links:</p>
<p>Click on the protocol name on the above article to go to relevant page. And some more links below.</p>
<p><a href="http://hessian.caucho.com/doc/hessian-serialization.html#anchor2">http://hessian.caucho.com/doc/hessian-serialization.html#anchor2</a></p>
<p><a href="http://github.com/blog/531-introducing-bert-and-bert-rpc">http://github.com/blog/531-introducing-bert-and-bert-rpc</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[R has a JSON package]]></title>
<link>http://nsaunders.wordpress.com/2009/11/06/r-has-a-json-package/</link>
<pubDate>Thu, 05 Nov 2009 23:44:44 +0000</pubDate>
<dc:creator>nsaunders</dc:creator>
<guid>http://nsaunders.wordpress.com/2009/11/06/r-has-a-json-package/</guid>
<description><![CDATA[Named rjson, appropriately. It&#8217;s quite basic just now, but contains methods for interconversio]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Named <a href="http://cran.r-project.org/web/packages/rjson/index.html">rjson</a>, appropriately.  It&#8217;s quite basic just now, but contains methods for interconversion between R objects and JSON.  Something like this:</p>
<pre class="brush: bash;">
&#62; library(rjson)
&#62; data &#60;- list(a=1,b=2,c=3)
&#62; json &#60;- toJSON(data)
&#62; json
[1] &#34;{\&#34;a\&#34;:1,\&#34;b\&#34;:2,\&#34;c\&#34;:3}&#34;
&#62; cat(json, file=&#34;data.json&#34;)
</pre>
<p>Use cases?  I wonder if <a href="http://biostat.mc.vanderbilt.edu/rapache/">RApache</a> could be used to build an API that serves R data in JSON format?</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[jQuery autocomplete plugin with ASMX web service and JSON]]></title>
<link>http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</link>
<pubDate>Wed, 04 Nov 2009 23:24:03 +0000</pubDate>
<dc:creator>Adam Mokan</dc:creator>
<guid>http://adammokan.wordpress.com/2009/11/04/jquery-autocomplete-plugin-with-asmx-web-service-and-json/</guid>
<description><![CDATA[I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m trying to find more reasons to switch a lot of my js/ajax ui over to jQuery recently. This is due to my excursions into Rails and Sinatra outside of work, and also because I feel like some of the MS Ajax Toolkit extenders seem to be bloated at times. I also figure that since I intend to dip my feet more into the ASP.NET MVC framework, jQuery seems to be very standard there.</p>
<p>That brings me to (one of) the jQuery Autocomplete plugins. I need this functionality in an ASP.NET webforms application and wanted to give it a shot. I started messing with &#8220;jQuery Autocomplete plugin 1.1&#8243; by Jörn Zaefferer. You can find the code and info at <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/</a>.</p>
<p>I&#8217;m mostly interested in doing an autocomplete via a remote web service call that returns json data. The example in the zip file includes a little php page that just responds to a HTTP-GET and spits out some hard-coded json. I&#8217;m working in .NET, so I made a simple ASMX web service to query my database and return a DataTable as json. (Note &#8211; There are isues with the built-in serializer to return a DataTable as json. A google search will find you a number of functions or alternate ways to generate a json string from a DataTable.)</p>
<p>Right away, I found I was having problems with the autocomplete in this environment. First off, you have the whole issue with ASMX web methods only accepting a POST by default. This is easy to change, but not advised. You can find info on that issue here &#8211; <a href="http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/">http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/</a> and some other good info here &#8211; <a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/</a></p>
<p>You&#8217;ll also notice in the above blog links that there can often be issues when POST-ing to a web method with encoding set to json, that you will need to pass your json params as a string. If you&#8217;re using something like Firebug to watch your ajax posts, you&#8217;ll catch this right away.</p>
<p>But the main issue for me were the assumptions that the autocomplete plugin makes. It, by default, will only do a HTTP-GET. You can use the $.ajaxSetup in jQuery to set your future ajax calls to a default, but I wanted the ability to make this decision when calling the autocomplete plugin.</p>
<p>I made these changes to jquery.autocomplete.js in the $.ajax section :<br />
<code>$.ajax({<br />
// try to leverage ajaxQueue plugin to abort previous requests<br />
mode: "abort",<br />
// limit abortion to this input<br />
port: "autocomplete" + input.name,<br />
dataType: options.dataType,<br />
//setup new options for asmx - amokan<br />
<strong>type: options.httpMethod,<br />
contentType: options.contentType,</strong><br />
//end new options - amokan<br />
url: options.url,</code></p>
<p>This allows me to now handle my client side code a little better.<br />
<code><br />
$("#task").autocomplete(<br />
"http://somecomputername/jsonServiceTest/Testing.asmx/GetData",<br />
{<br />
dataType: 'json',<br />
<strong>httpMethod: 'POST',<br />
contentType: 'application/json; charset=utf-8',</strong><br />
max: 100,<br />
scroll: true,<br />
matchContains: true,<br />
minChars: 3,<br />
parse: function(data) {<br />
var rows = new Array();<br />
//your parsing logic<br />
},<br />
formatItem: function(row, i, n) {<br />
//do something<br />
},<br />
width: 260<br />
}<br />
);<br />
</code></p>
<p>I&#8217;m still working on cleaning up the data parameter section of the plugin a bit before I post the full code.</p>
<p>If you&#8217;re curious, here is my ASMX method. Be sure to add the [ScriptService] attribute to your class in the ASMX file so it can handle AJAX properly. If you are using an older .NET without the System.Web.Script.Services namespace, this will not work for you. Note that the parameters &#8220;q&#8221; and &#8220;limit&#8221; are sent automatically by the autocomplete plugin. &#8220;Q&#8221; is the string currently typed into the text control so you can filter your query based on what the user has typed and &#8220;limit&#8221; is the max number of rows. Obviously, its up to you to implement these in your query if you chose to.</p>
<p><code><br />
[WebMethod]<br />
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]<br />
public string GetATCDataNoParam(string q, int limit)<br />
{<br />
DataTable dtSomething;</code></p>
<p>//connect to db, do your exception handling, etc<br />
dtSomething = //your DAL or whatever you use</p>
<p>return GetJSONString(dtSomething); //use my method to parse the datatable into json<br />
}</p>
<p>Hope this helps a bit and I will be sure to upload some more code as I get this working a bit smoother in my environment.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[FireFox 3.5.4]]></title>
<link>http://dancotofanu.wordpress.com/2009/11/03/firefox-3-5-4/</link>
<pubDate>Tue, 03 Nov 2009 10:19:36 +0000</pubDate>
<dc:creator>dancotofanu</dc:creator>
<guid>http://dancotofanu.wordpress.com/2009/11/03/firefox-3-5-4/</guid>
<description><![CDATA[New cool stuff in FireFox 3.5 [link] Native JSON: JSON.parse(), JSON.stringify() [link] Web Workers:]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>New cool stuff in <strong>FireFox 3.5</strong></p>
<ol>
<li>[<a target="_blank" href="https://developer.mozilla.org/En/Using_JSON_in_Firefox">link</a>] <strong>Native JSON</strong>: JSON.parse(), JSON.stringify() </li>
<li>[<a target="_blank" href="https://developer.mozilla.org/En/Using_web_workers">link</a>] <strong>Web Workers</strong>: var w = new Worker(&#8217;script.js&#8217;); </li>
<li>[<a target="_blank" href="https://developer.mozilla.org/En/Offline_resources_in_Firefox">link</a>] <strong>Offline resources</strong>: &#60;html manifest=&#8221;foo.manifest&#8221;&#62; </li>
</ol>
<p>BTW: Since Firefox 3.5 they added <strong><a target="_blank" href="https://developer.mozilla.org/en/firefox_3.5_for_developers#HTML.c2.a05_support">HTML5 support</a></strong>.</p>
<p>What are you waiting for?</p>
<ul>
<li><a href="http://download.mozilla.org/?product=firefox-3.5.4&#38;os=win&#38;lang=en-US">Download Mozilla FireFox 3.5.4</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Announcing iKaenkky]]></title>
<link>http://mikkopa.wordpress.com/2009/11/02/announcing-ikaenkky/</link>
<pubDate>Mon, 02 Nov 2009 15:32:50 +0000</pubDate>
<dc:creator>pallarim</dc:creator>
<guid>http://mikkopa.wordpress.com/2009/11/02/announcing-ikaenkky/</guid>
<description><![CDATA[Based on a popular website, Kaenkky.com, I&#8217;m proud to present first version of iKaenkky. iKaen]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://mikkopa.wordpress.com/files/2009/11/ikaenkky1.jpg"><img class="alignnone size-medium wp-image-76" title="iKaenkky1" src="http://mikkopa.wordpress.com/files/2009/11/ikaenkky1.jpg?w=154" alt="iKaenkky1" width="154" height="300" /></a> <a href="http://mikkopa.wordpress.com/files/2009/11/ikaenkky2.jpg"><img class="alignnone size-medium wp-image-77" title="iKaenkky2" src="http://mikkopa.wordpress.com/files/2009/11/ikaenkky2.jpg?w=154" alt="iKaenkky2" width="154" height="300" /></a> <a href="http://mikkopa.wordpress.com/files/2009/11/ikaenkky3.jpg"><img class="alignnone size-medium wp-image-78" title="iKaenkky3" src="http://mikkopa.wordpress.com/files/2009/11/ikaenkky3.jpg?w=154" alt="iKaenkky3" width="154" height="300" /></a></p>
<p>Based on a popular website, <a title="kaenkky.com" href="http://www.kaenkky.com/" target="_blank">Kaenkky.com</a>, I&#8217;m proud to present first version of iKaenkky. iKaenkky is an iPhone software which locates pizza, kebab or other kaenkky places near you. The places are fetched from kaenkky.com service which is very popular in Oulu area, but also restaurants from other cities exist in the service.</p>
<p>The software fetches restaurant information from kaenkky.com API with REST in JSON format. On iPhone side I used <a title="JSON framework" href="http://code.google.com/p/json-framework/" target="_blank">objective-c JSON framework</a> to parse the data and <a title="iPhone google maps component" href="http://code.google.com/p/iphone-google-maps-component/" target="_blank">iphone-google-maps-component</a> to display all data. Location information is fetched with iPhones own CoreLocation component.</p>
<p>iKaenkky is still in very early stage and there is tons of stuff to improve. Some people will get it for testing as early beta quite soon, but full release date is yet to be announced.</p>
<p><span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/zHXG7ZXiNQw&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' /><param name='allowfullscreen' value='true' /><param name='wmode' value='transparent' /><embed src='http://www.youtube.com/v/zHXG7ZXiNQw&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;hd=0' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='transparent'></embed></object></span></p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
