Skip to content

Commit 6be72b3

Browse files
limingxinleohuangzhhui
authored andcommitted
Validator增加Json格式支持 (swoft-cloud/swoft-component#122)
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
1 parent c9e871d commit 6be72b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Server/Concerns/InteractsWithInput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Swoft\Http\Message\Server\Concerns;
44

5+
use Swoft\Helper\ArrayHelper;
56
use Swoft\Helper\JsonHelper;
67
use Swoft\Http\Message\Stream\SwooleStream;
78

@@ -150,7 +151,7 @@ public function json(string $key = null, $default = null)
150151
if (is_null($key)) {
151152
return $decodedBody ?? $default;
152153
} else {
153-
return $decodedBody[$key] ?? $default;
154+
return ArrayHelper::get($decodedBody, $key, $default);
154155
}
155156
}
156157

0 commit comments

Comments
 (0)