encode() public static method

encode object to json
public static encode ( mixed $object, $options ) : string
$object mixed
return string json
Esempio n. 1
0
 function pageEntry($inPath)
 {
     $sm = new SJson();
     $testObject = new stdclass();
     $testObject->name = "SlightPHP";
     $testObject->value = array("min" => 1, "max" => 999);
     /**
      * 编码
      */
     print_r($tmp = $sm->encode($testObject));
     echo "\n";
     /**
      * 解码
      */
     print_r($sm->decode($tmp));
 }
Esempio n. 2
0
 public static function args2str($args)
 {
     self::obj2str($args);
     $tmp = SJson::encode($args);
     $tmp = str_replace("\\/", "/", $tmp);
     return substr($tmp, 1, strlen($tmp) - 2);
 }