title: NuSoap create JSON response
body: <p>Today I have been created a simple WebServices Server with SOAP using "Nusoap" library. The response data of course in XML format.</p>
  
  <p>My Server code:</p>
  
  <pre><code>&lt;?php
  require_once "nusoap.php";
  
  function pLogin($username, $password) {
      if (($username == "admin")&amp;&amp;($password == md5("123456"))) {
          //return "AAAAAAAAAA Login OK";
          return (array("cmd" =&gt; "LOGIN","status" =&gt; "LOGINOK","fullname" =&gt; "John Smith", "phone" =&gt; "0987654321", "credit" =&gt; "5600", "session" =&gt; "ID24324343434"));
      }
      else {
              return "Login Fail";
      }
  }
  
  $server = new soap_server();
  $server-&gt;register("pLogin");
  $server-&gt;service($HTTP_RAW_POST_DATA);
  ?&gt;
  </code></pre>
  
  <p>And the HTTP response as:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;ns1:pLoginResponse xmlns:ns1="http://tempuri.org"&gt;
              &lt;return&gt;
                  &lt;cmd xsi:type="xsd:string"&gt;LOGIN&lt;/cmd&gt;
                  &lt;status xsi:type="xsd:string"&gt;LOGINOK&lt;/status&gt;
                  &lt;fullname xsi:type="xsd:string"&gt;John Smith&lt;/fullname&gt;
                  &lt;phone xsi:type="xsd:string"&gt;0987654321&lt;/phone&gt;
                  &lt;credit xsi:type="xsd:string"&gt;5600&lt;/credit&gt;
                  &lt;session xsi:type="xsd:string"&gt;ID24324343434&lt;/session&gt;
              &lt;/return&gt;
          &lt;/ns1:pLoginResponse&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>But I want to create the response data in JSON format, like or :</p>
  
  <pre><code>HTTP/1.1 200 OK
  .... (HTTP header here)
  Content-Type: text/json
  {"cmd":"LOGIN","status":"LOGINOK","fullname":"John Smith","phone":"0987654321","credit":"5600","session":"ID24324343434"}
  </code></pre>
  
  <p>Please help me to modify the code in WebServices server to create the JSON format data.</p>