File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ public function getParsedBody(bool $reload = false)
6969 $ type = $ this ->getHeader ('Content-Type ' );
7070 $ body = $ this ->getBody ();
7171 try {
72- if (' application/json ' === $ type ) {
72+ if (false !== strpos ( $ type, ' application/json ' ) ) {
7373 $ this ->parsedBody = json_decode ($ body );
7474 }
7575 } catch (\Exception $ e ) {
@@ -85,13 +85,14 @@ public function getParsedBody(bool $reload = false)
8585 /**
8686 * Получение тела с преобразованием json.
8787 * @return object|null
88+ * @param bool|null парсить ли json в массив
8889 * @throws HttpException
8990 */
90- public function getJsonParsedBody (): ?object
91+ public function getJsonParsedBody (bool $ toArray = false ): ?object
9192 {
9293 $ body = $ this ->getBody ();
9394 try {
94- $ decoded = json_decode ($ body );
95+ $ decoded = json_decode ($ body, $ toArray );
9596 return $ decoded ?? null ;
9697 } catch (\Exception $ e ) {
9798 throw new HttpException ("Failed to parse json body: $ body " );
You can’t perform that action at this time.
0 commit comments