diff --git a/src/Lib/Http/Body.php b/src/Lib/Http/Body.php index f4df420..fbc66ce 100644 --- a/src/Lib/Http/Body.php +++ b/src/Lib/Http/Body.php @@ -90,17 +90,24 @@ public function getBody(): array /** * Returns body data by key * - * @param string $key + * @param string $key * @param mixed $default * @return mixed */ public function getBodyData(string $key, $default = null) { - return array_key_exists($key, $this->body) ? $this->body[$key] : $default; + // return array_key_exists($key, $this->body) ? json_encode($this->body[$key]) : $default; + if (array_key_exists($key, $this->body)) { + if (is_string($this->body[$key])) { + return $this->body[$key]; + } else { + return json_encode($this->body[$key]); + } + } else { + return $default; + } } - - /** * Returns body content type *