Thenbsp\Wechat\Bridge\Serializer::jsonEncode PHP Метод

jsonEncode() публичный статический Метод

json encode
public static jsonEncode ( $data, array $context = [] )
$context array
    public static function jsonEncode($data, array $context = array())
    {
        $defaults = array('json_encode_options' => defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0);
        return (new JsonEncoder())->encode($data, 'json', array_replace($defaults, $context));
    }

Usage Example

Пример #1
0
 /**
  * 获取配置
  */
 public function getConfig($asArray = false)
 {
     $options = array('appid' => $this->accessToken->getAppid(), 'url' => Util::getCurrentUrl(), 'timestamp' => Util::getTimestamp(), 'noncestr' => Util::getRandomString(), 'accesstoken' => $this->accessToken['access_token']);
     // 按 ASCII 码排序
     ksort($options);
     $signature = http_build_query($options);
     $signature = urldecode($signature);
     $signature = sha1($signature);
     $config = array('appId' => $options['appid'], 'scope' => 'jsapi_address', 'signType' => 'sha1', 'addrSign' => $signature, 'timeStamp' => $options['timestamp'], 'nonceStr' => $options['noncestr']);
     return $asArray ? $config : Serializer::jsonEncode($config);
 }
All Usage Examples Of Thenbsp\Wechat\Bridge\Serializer::jsonEncode