hyperf-chat/app/Helper/JsonHelper.php

35 lines
555 B
PHP
Raw Normal View History

2021-09-04 18:07:53 +08:00
<?php
declare(strict_types=1);
2022-01-22 20:08:19 +08:00
namespace App\Helper;
2021-09-04 18:07:53 +08:00
/**
* Json 字符串助手
*
* @package App\Helpers
*/
class JsonHelper
{
/**
* Json 字符串解析
*
* @param $value
* @return mixed
*/
public static function decode($value)
{
return json_decode($value, true);
}
/**
* Json 加密
*
* @param $value
* @return false|string
*/
public static function encode($value)
{
return json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
}