title: C# Add item to JSON
body: <p>Can anyone tell me how can I add a new student?
  I began to learn to work with json. I tried to read, delete or rename something in json. It works well, but i have problem with add a new student.. :</p>
  
  <pre><code>        StreamReader input = new StreamReader("student.txt");
          string kontext = input.ReadToEnd();
          input.Close();
  
          JSONNode j = JSONNode.Parse(kontext);
  
          Console.WriteLine("ID: ");
          string c = "\"" + Console.ReadLine() + "\"";
  
          //write to console name and surname by id
          int n = j["student"].Count;
          for (int i = 0; i &lt; n; i++)
          {
              string temp = j["student"][i][0].ToString("");
               if(c == temp)
               {
                   Console.WriteLine(j["student"][i]["name"]);
                   Console.WriteLine(j["student"][i]["surname"]);
               }
          }
  
          //rename by id + save to json
              Console.WriteLine("ID: ");
              c = "\"" + Console.ReadLine() + "\"";
              for (int i = 0; i &lt; j["student"].Count; i++)
              {
                  string temp = j["student"][i][0].ToString("");
                  if (c == temp)
                  {
                      Console.Write("New name: ");
                      string rename = Console.ReadLine();
                      j["student"][i]["meno"] = rename;
  
                      StreamWriter output = new StreamWriter("student.txt");
                      output.WriteLine(j.ToString(""));
                      output.Close();
                      Console.WriteLine(j["student"][i]["meno"]);
  
                  }
              }
  
          //remove by id
              Console.WriteLine("ID: ");
              c = "\"" + Console.ReadLine() + "\"";
              for (int i = 0; i &lt; j["student"].Count; i++)
              {
                  string temp = j["student"][i][0].ToString("");
                  if (c == temp)
                  {
                      j["student"].Remove(i);
                      StreamWriter output = new StreamWriter("student.txt");
                      output.WriteLine(j.ToString(""));
                      output.Close();
  
                  }
              }
  
          //add new student
  
          Console.ReadKey();
      }
  </code></pre>
  
  <p>Here is my response
  <img src="https://i.stack.imgur.com/f7csf.jpg" alt="enter image description here"></p>