title: Azure Function return multiple JSON objects
body: <p>This is my azure function app.</p>
  
  <pre><code>#r "System.Configuration"
  #r "System.Data"
  using System.Net;
  using System.Configuration;
  using System.Data.SqlClient;
  using System.Threading.Tasks;
  
  public static async Task&lt;HttpResponseMessage&gt; Run(HttpRequestMessage req, 
  TraceWriter log)
  {       
      int num;    
      string query = req.GetQueryNameValuePairs()
          .FirstOrDefault(q =&gt; string.Compare(q.Key, "num", true) == 0)
          .Value;    
  
      if (query == null)
      {
          // Get request body
          dynamic data = await req.Content.ReadAsAsync&lt;object&gt;();
          num = data.num;
      }
      else {
          num = Convert.ToInt32(query);
      }      
  
      int[] numRead = new int[3];
      string[] nameRead = new string[3];    
  
      var str = 
  ConfigurationManager.ConnectionStrings["sqldb_connection"].ConnectionString;
  
      using (SqlConnection conn = new SqlConnection(str))
      {
          conn.Open();
          var text = "select num,name from bus where num=@num;";
  
          using (SqlCommand cmd = new SqlCommand(text, conn))
          {
              cmd.Parameters.AddWithValue("@num", num);
              using (SqlDataReader reader = cmd.ExecuteReader()) 
              {
                  int i = 0;
                  while (reader.Read())
                  {
                      numRead[i] = reader.GetInt32(0);                    
                      nameRead[i++] = reader.GetString(1);
                      Console.WriteLine(numRead[i] + ":" + nameRead[i]);                    
                  }
              }
          }        
      }
      return req.CreateResponse(HttpStatusCode.OK, new {            
          name = nameRead[0],
          num = numRead[0]           
      });    
  }
  </code></pre>
  
  <p>I want the function to return multiple json like this</p>
  
  <pre><code>return req.CreateResponse(HttpStatusCode.OK, new {
          "item1" : {
              name = nameRead[0],
              num = numRead[0]
          },
          "item2" : {
              name = nameRead[1],
              num = numRead[1]
          },
          "item3" : {
              name = nameRead[2],
              num = numRead[2]
          }
      });
  </code></pre>
  
  <p>but it doesn't work.</p>
  
  <p>C# has <code>JsonArray</code>, <code>JsonObject</code> or <code>JsonValue</code> class, but I don't understand how to use them and don't know the difference between them.</p>