REST Web サービスから json を取得する方法を教えてください。
私のコードは以下のとおりです
ここでアプリケーションを実行すると、たとえば
localhost/examples/Example.php?method=addInts&n1=3&n2=5
次のような出力が得られます
{"Result":"3 + 5 = 8"}
どうすれば出力をjsonとして返すことが期待できますか
[{"Result":8}]
私のphpコード
<?php
  require_once "../Rest.php";
  class Hello
  {
     // example: http://path/to/examples/Example.php?method=sayHello&name=World
     public static function sayHello($name)
     {
        return array("Response" => "Hello, " . $name);
     }
     // example: http://path/to/examples/Example.php?method=addInts&n1=3&n2=5
     public static function addInts($n1, $n2)
     {
        if (is_numeric($n1) && is_numeric($n2))
        {
          return array("Result" => "$n1 + $n2 = " . (string)($n1 + $n2));
        }
        else
        {
          return array("Error" => "Parameters must be numeric.");
        }
     }
  }
  $rest = new Server(Hello);
  $rest->handle();
?>