title: How to create JSON data with .NET?
body: <p>At the moment, I am building json data as follows:</p>
  
  <pre><code>&lt;%@ Page Language="VB" Debug="True" EnableViewState="false" %&gt;
  
  &lt;%@ Import Namespace="System.Data" %&gt;
  &lt;%@ Import Namespace="System.Data.SqlClient" %&gt;
  &lt;%@ Import Namespace="System.IO" %&gt;
  
  &lt;script runat="server"&gt;
      Dim objSQLConnection As SqlConnection
      Dim objSQLCommand As SqlCommand
      Dim objSQLDataReader As SqlDataReader
      Dim objJSONStringBuilder As StringBuilder
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
          Response.Clear()
          Response.ContentType = "application/json"
          Response.Write(get_json())
          Response.End()
      End Sub
  
      Function get_json() As String
          objJSONStringBuilder = New StringBuilder()
          objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))
  
          objSQLCommand = New SqlCommand("sql query goes here", objSQLConnection)
  
          objJSONStringBuilder.Append("[")
  
          objSQLCommand.Connection.Open()
          objSQLDataReader = objSQLCommand.ExecuteReader()
  
          While objSQLDataReader.Read()
              objJSONStringBuilder.Append("{")
              objJSONStringBuilder.Append("""col1""")
              objJSONStringBuilder.Append(":")
              objJSONStringBuilder.Append("""" &amp; objSQLDataReader("col1") &amp; """")
              objJSONStringBuilder.Append(",")
              objJSONStringBuilder.Append("""col2""")
              objJSONStringBuilder.Append(":")
              objJSONStringBuilder.Append("""" &amp; objSQLDataReader("col2") &amp; """")
              objJSONStringBuilder.Append(",")
              objJSONStringBuilder.Append("""col3""")
              objJSONStringBuilder.Append(":")
              objJSONStringBuilder.Append("""" &amp; objSQLDataReader("col3") &amp; """")
              objJSONStringBuilder.Append("},")
          End While
  
          objSQLDataReader.Close()
          objSQLCommand.Connection.Close()
  
          objJSONStringBuilder.Remove(objJSONStringBuilder.Length - 1, 1)
  
          objJSONStringBuilder.Append("]")
  
          Return objJSONStringBuilder.ToString
      End Function
  &lt;/script&gt;
  </code></pre>
  
  <p>Is this the preferred method of creating JSON data using .NET?</p>
  
  <p>I think I am supposed to use asmx web services with arrays converted to json?  But all the examples I have seen are in C#.</p>