title: How to send json data to RESTful API in Unity3D?
body: <p>Good afternoon friends!</p>
  
  <p>I am a programmer and I'm a little time learning about the Unity and the game development universe. I came a doubt that I could not find the answer very well.
  What is the best architecture or solution to work with a mobile multiplayer game using a restful webservice? It's possible? It is the best way to do something online multiplayer?</p>
  
  <p>I've been studying a bit WWWForm class and tried to simulate sending data via JSON using JSONObject but without much success. I can not actually send a javascript object.</p>
  
  <p>An example:</p>
  
  <pre><code>public void enviar(JSONObject json, Objeto obj)
  {
      string url = "http://myurl/unity.php";
  
      WWWForm form = new WWWForm();
  
      form.AddField("var1", "[{\"Nome\":\""+obj.name+"\"}]");
  
      WWW www = new WWW(url, form);
  
      StartCoroutine(WaitForRequest(www));
  }
  
  IEnumerator WaitForRequest(WWW www)
  {
      yield return www;
  
          // check for errors
      if(www.error == null)
      {
          Debug.Log("WWW Ok!: " + www.text);
      } else {
          Debug.Log("WWW Error: "+ www.error);
      }    
  } 
  </code></pre>
  
  <p>and my PHP file I have the following test:</p>
  
  <pre><code>$t = $_POST['var1'];
  $novot = json_decode($t);
  
  foreach ($novot as $novo){
  $fp = fopen("bloco1.txt", "a");
  
  $escreve = fwrite($fp, $novo);
  
  fclose($fp);
  }
  </code></pre>
  
  <p>All I can back is a stdClass, I can handle, but that to me is something very manual. There is no simple and correct way of working with webservices?</p>