<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>afasyah.web.id &#187; JSON</title>
	<atom:link href="http://afasyah.web.id/category/json/feed/" rel="self" type="application/rss+xml" />
	<link>http://afasyah.web.id</link>
	<description>Me, Myself and a Wordpress</description>
	<lastBuildDate>Thu, 24 Dec 2009 02:14:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Konversi dataset ke JSON</title>
		<link>http://afasyah.web.id/aspnet/konversi-dataset-ke-json/</link>
		<comments>http://afasyah.web.id/aspnet/konversi-dataset-ke-json/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 12:04:07 +0000</pubDate>
		<dc:creator>danni</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Dataset]]></category>
		<category><![CDATA[Javasript]]></category>

		<guid isPermaLink="false">http://afasyah.web.id/konversi-dataset-ke-json/</guid>
		<description><![CDATA[Setelah muter2 ketemu juga akhirnya. Biar gampangnya, serialisasi ke JSON menggunakan library JSON.NET, di websitenya ada beberapa versi tergantung versi .net framework yang digunakan. BTW, ini kodenya : 1: Imports Newtonsoft.Json 2: Private Function GetCustomer() As String 3: Dim retVal As String = "" 4: Dim ds As DataSet = DAL.Customer.GetCustomers 5: 6: If ds [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Setelah muter2 ketemu juga akhirnya. Biar gampangnya, serialisasi ke <a href="http://id.wikipedia.org/wiki/JSON" target="_blank">JSON</a> menggunakan library <a href="http://james.newtonking.com/pages/json-net.aspx" target="_blank">JSON.NET</a>, di websitenya ada beberapa versi tergantung versi .net framework yang digunakan. BTW, ini kodenya :</p>
<div id="codeSnippetWrapper" style="border: 1px solid silver; margin: 20px 0px 10px; padding: 4px; overflow: auto; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; cursor: text;">
<div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #0000ff">Imports</span> Newtonsoft.Json</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum2" style="color: #606060">   2:</span> <span style="color: #0000ff">Private</span> <span style="color: #0000ff">Function</span> GetCustomer() <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum3" style="color: #606060">   3:</span>     <span style="color: #0000ff">Dim</span> retVal <span style="color: #0000ff">As</span> <span style="color: #0000ff">String</span> = <span style="color: #006080">""</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum4" style="color: #606060">   4:</span>     <span style="color: #0000ff">Dim</span> ds <span style="color: #0000ff">As</span> DataSet = DAL.Customer.GetCustomers</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum5" style="color: #606060">   5:</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum6" style="color: #606060">   6:</span>     <span style="color: #0000ff">If</span> ds IsNot <span style="color: #0000ff">Nothing</span> <span style="color: #0000ff">AndAlso</span> ds.Tables(0).Rows.Count &gt; 0 <span style="color: #0000ff">Then</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum7" style="color: #606060">   7:</span>         <span style="color: #0000ff">Dim</span> custList <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> List(Of Hashtable)()</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum8" style="color: #606060">   8:</span>         <span style="color: #0000ff">For</span> i <span style="color: #0000ff">As</span> <span style="color: #0000ff">Integer</span> = 0 <span style="color: #0000ff">To</span> ds.Tables(0).Rows.Count - 1</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum9" style="color: #606060">   9:</span>             <span style="color: #0000ff">Dim</span> ht <span style="color: #0000ff">As</span> <span style="color: #0000ff">New</span> Hashtable()</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum10" style="color: #606060">  10:</span>             <span style="color: #0000ff">Dim</span> row <span style="color: #0000ff">As</span> DataRow = <span style="color: #0000ff">TryCast</span>(ds.Tables(0).Rows(i), DataRow)</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum11" style="color: #606060">  11:</span>             ht(<span style="color: #006080">"IDCustomer"</span>) = Convert.ToString(row(<span style="color: #006080">"IDCustomer"</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum12" style="color: #606060">  12:</span>             ht(<span style="color: #006080">"CustomerName"</span>) = Convert.ToString(row(<span style="color: #006080">"CustomerName"</span>))</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum13" style="color: #606060">  13:</span>             custList.Add(ht)</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum14" style="color: #606060">  14:</span>         <span style="color: #0000ff">Next</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum15" style="color: #606060">  15:</span>         retVal = JavaScriptConvert.SerializeObject(custList)</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum16" style="color: #606060">  16:</span>     <span style="color: #0000ff">End</span> <span style="color: #0000ff">If</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum17" style="color: #606060">  17:</span></pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum18" style="color: #606060">  18:</span>     <span style="color: #0000ff">Return</span> retVal</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum19" style="color: #606060">  19:</span> <span style="color: #0000ff">End</span> Function</pre>
<p><!--CRLF--></div>
</div>
<p>Output yang dihasilkan adalah sebagai berikut (setelah dirapikan):</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="border-style: none; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;">
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum1" style="color: #606060">   1:</span> [</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum2" style="color: #606060">   2:</span> {<span style="color: #006080">"IDCustomer"</span>:<span style="color: #006080">"1"</span>,<span style="color: #006080">"CustomerName"</span>:<span style="color: #006080">"Unyil"</span>},</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum3" style="color: #606060">   3:</span> {<span style="color: #006080">"IDCustomer"</span>:<span style="color: #006080">"2"</span>,<span style="color: #006080">"CustomerName"</span>:<span style="color: #006080">"Cuplis"</span>},</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum4" style="color: #606060">   4:</span> {<span style="color: #006080">"IDCustomer"</span>:<span style="color: #006080">"3"</span>,<span style="color: #006080">"CustomerName"</span>:<span style="color: #006080">"Ableh"</span>}</pre>
<p><!--CRLF--></p>
<pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; text-align: left; line-height: 12pt; background-color: white; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt;"><span id="lnum5" style="color: #606060">   5:</span> ]</pre>
<p><!--CRLF--></div>
</div>
<!-- PHP 5.x -->

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://afasyah.web.id/aspnet/konversi-dataset-ke-json/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
