title: How to insert C# string into JSON string
body: <p>How to insert string <code>sUsername</code> to <code>myEmail</code> and <code>sPassword</code> to<code>myPassword</code>? </p>
  
  <p><code>sUsername</code> and <code>sPassword</code> are from the login form. </p>
  
  <p>I'm just learning JSON, can I make a JSON variable and fill it with <code>sUsername</code> and <code>sPassword</code> values?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void login(string sUsername, string sPassword)
  {
      var httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://atsiri.online/api/v1.php");
      httpWebRequest.ContentType = "application/json";
      httpWebRequest.Method = "POST";
  
      using (var streamWriter = new System.IO.StreamWriter(httpWebRequest.GetRequestStream()))
      {
          string json = @"
          {
              ""type"":""login"",
              ""condition"":{
                  ""0"":{
                      ""key"":""email"",
                      ""value"":""myEmail""
                  },
                  ""1"":{
                      ""key"":""password"",
                      ""value"":""myPassword""
                  }
              }
          }";
  
          streamWriter.Write(json);
          streamWriter.Flush();
          streamWriter.Close();
      }
  
      var httpResponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse();
      using (var streamReader = new System.IO.StreamReader(httpResponse.GetResponseStream()))
      {
          var result = streamReader.ReadToEnd();
          Console.WriteLine(result.ToString());
      }
  }
  </code></pre>