public function getJson(string $type = 'object')
    {
        if ($this->getMediaType() !== 'application/json') {
            return $json = $type === 'array' ? [] : (object) [];
        }
        if ($type === 'array') {
            $json        = $this->getParsedBody();
            return $json = is_array($json) ? $json : [];
            //
        } elseif ($type === 'object') {
            $json        = $this->getParsedBody();
            return $json = $json instanceof \StdClass ? $json : (object) [];
            //
        } else { // Array or object — either.
            $json        = $this->getParsedBody();
            return $json = is_array($json) || is_object($json) ? $json : (object) [];
        }
    }
public function getJson(string $type = 'object')
    {
        if ($this->getMediaType() !== 'application/json') {
            return $json = $type === 'array' ? [] : (object) [];
        }
        if ($type === 'array') {
            $json        = $this->getParsedBody();
            return $json = is_array($json) ? $json : [];
            //
        } elseif ($type === 'object') {
            $json        = $this->getParsedBody();
            return $json = $json instanceof \StdClass ? $json : (object) [];
            //
        } else { // Array or object — either.
            $json        = $this->getParsedBody();
            return $json = is_array($json) || is_object($json) ? $json : (object) [];
        }
    }
public function getJson ( string $ type = 'object' ) { if ( $ this -> getMediaType ( ) !== 'application/json' ) { return $ json = $ type === 'array' ? [ ] : ( object ) [ ] ; } if ( $ type === 'array' ) { $ json = $ this -> getParsedBody ( ) ; return $ json = is_array ( $ json ) ? $ json : [ ] ; // } elseif ( $ type === 'object' ) { $ json = $ this -> getParsedBody ( ) ; return $ json = $ json instanceof \ StdClass ? $ json : ( object ) [ ] ; // } else { // Array or object — either. $ json = $ this -> getParsedBody ( ) ; return $ json = is_array ( $ json ) || is_object ( $ json ) ? $ json : ( object ) [ ] ; } }
Get parsed JSON body.

@since 17xxxx Request object.

@param string $type Expected data return type.
One of: `array`, `object`, `any`.

@return \StdClass|array Body as object|array.
Get parsed JSON body .