function testFun() { $remote = PHPJAO::createRemoteProxy("http://127.0.0.1:8080/JSON-RPC", "testBean"); $p1 = $remote->getP5(1); var_dump($p1); }
<?php require_once 'PHPJAO.php'; if (PHPJAO::isPhpList(array(1, 2, 3, 4))) { echo "OK"; } else { echo "Error 1"; } ?>
<?php require_once 'generated.php'; $serialized = '{ "javaClass": "ua.gradsoft.t5.T5Dao", "id":1 , "en": "ONE" }'; $s1 = json_decode($serialized, true); $json_error = json_last_error(); if ($json_error != JSON_ERROR_NONE) { echo "json_error={$json_error}\n"; if ($json_error == JSON_ERROR_SYNTAX) { echo 'JSON_EROR_SYNTAX' . "\n"; } } $result = PHPJAO::fromJson($s1); if ($result->id == 1) { echo 'OK'; } else { echo 'ERROR'; } echo "\n"; if ($result->en == 'ONE') { echo 'OK'; } else { echo 'ERROR'; }
public static function fromJson($object) { # transform to TreeMap if (is_array($object)) { $l = $object['map']; return PHPJAO::fromJson($l); } else { throw new PHPJAOMarshallingException("can't transform TreeMap from JSON"); } }
<?php require_once 'PHPJAO.php'; class E1PHPJAOClassDescription extends PHPJAOClassDescription { public function __construct() { parent::__construct(); $this->javaClass = 'ua.gradsoft.t1.E1'; $this->phpClass = 'E1'; $this->typesOfFields = array('name' => 'java.lang.String', 'value' => 'java.lang.String', 'truth' => 'java.lang.Boolean'); } public function newInstance() { return new E1(); } } class E1 extends PHPJAOPOJOBase { static $phpjaoClassDescription; public function getPHPJAOClassDescription() { return self::$phpjaoClassDescription; } public $name; public $value; public $truth; } E1::$phpjaoClassDescription = new E1PHPJAOClassDescription(); PHPJAO::registerType('ua.gradsoft.t1.E1', E1::$phpjaoClassDescription);
<?php require_once 'PHPJAO.php'; $jsonArray = array('javaClass' => 'java.util.Date', time => 0); $o = PHPJAO::fromJson($jsonArray); if (get_class($o) == 'DateTime') { echo "OK\n"; } else { echo "Error: must be converted to datetime \n"; } if ($o->format('U') == '0') { echo 'OK'; } else { echo 'Error'; } echo "\n"; $narr = json_encode(PHPJAO::toJson($o)); # echo "narr=${narr}\n"; # echo "class(narr)="+get_class($narr)+"\n"; if ($narr['time'] != null) { echo "OK\n"; } else { echo 'Error'; } ?>