<?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; Dataset</title>
	<atom:link href="http://afasyah.web.id/tag/dataset/feed/" rel="self" type="application/rss+xml" />
	<link>http://afasyah.web.id</link>
	<description>Me, Myself and a Wordpress</description>
	<lastBuildDate>Tue, 26 Oct 2010 10:41:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.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[Kode berikut berguna untuk mengkonversi dataset ke format JSON, untuk gampangnya, serialisasi ke JSON menggunakan library JSON.NET, di websitenya ada beberapa versi tergantung versi .net framework yang digunakan. BTW, ini kodenya : Output yang dihasilkan adalah sebagai berikut (setelah dirapikan):]]></description>
			<content:encoded><![CDATA[<p>Kode berikut berguna untuk mengkonversi dataset ke format JSON, untuk 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>
<pre class="brush: vb; title: ; notranslate">
Imports Newtonsoft.Json

	Private Function GetCustomer() As String

		Dim retVal As String = &quot;&quot;
		Dim ds As DataSet = DAL.Customer.GetCustomers

		If ds IsNot Nothing AndAlso ds.Tables(0).Rows.Count &gt; 0 Then

		Dim custList As New List(Of Hashtable)()

		For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
			 Dim ht As New Hashtable()
			 Dim row As DataRow = TryCast(ds.Tables(0).Rows(i), DataRow)
			 ht(&quot;IDCustomer&quot;) = Convert.ToString(row(&quot;IDCustomer&quot;))
			 ht(&quot;CustomerName&quot;) = Convert.ToString(row(&quot;CustomerName&quot;))
			 custList.Add(ht)
		Next

		retVal = JavaScriptConvert.SerializeObject(custList)

		End If

		Return retVal

End Function
</pre>
<p>Output yang dihasilkan adalah sebagai berikut (setelah dirapikan):</p>
<pre class="brush: jscript; title: ; notranslate">
[
{&quot;IDCustomer&quot;:&quot;1&quot;,&quot;CustomerName&quot;:&quot;Unyil&quot;},
{&quot;IDCustomer&quot;:&quot;2&quot;,&quot;CustomerName&quot;:&quot;Cuplis&quot;},
{&quot;IDCustomer&quot;:&quot;3&quot;,&quot;CustomerName&quot;:&quot;Ableh&quot;}
]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://afasyah.web.id/aspnet/konversi-dataset-ke-json/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

