添加网站文件

This commit is contained in:
2025-12-22 13:59:40 +08:00
commit 117aaf83d1
19468 changed files with 2111999 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace Alipay\EasySDK\Kernel\Util;
use AlibabaCloud\Tea\Model;
class JsonUtil
{
public function toJsonString(array $input)
{
$result = [];
foreach ($input as $k => $v) {
if ($v instanceof Model) {
$result[$k] = $this->getTeaModelMap($v);
} else {
$result[$k] = $v;
}
}
return $result;
}
private function getTeaModelMap(Model $teaModel)
{
$result = [];
foreach ($teaModel as $k => $v) {
if ($v instanceof Model) {
$k = $this->toUnderScore($k);
$result[$k] = $this->getTeaModelMap($v);
} else {
if (empty($result)) {
$k = $this->toUnderScore($k);
$result[$k] = $v;
} else {
$k = $this->toUnderScore($k);
$result[$k] = $v;
}
}
}
return $result;
}
/**
* 驼峰命名转下划线命名
* @param $str
* @return string
*/
private function toUnderScore($str)
{
$dstr = preg_replace_callback('/([A-Z]+)/', function ($matchs) {
return '_' . strtolower($matchs[0]);
}, $str);
return trim(preg_replace('/_{2,}/', '_', $dstr), '_');
}
}