src/Error.php
public function jsonSerialize()
    {
        $json = [];

        foreach (['code', 'message', 'description', 'uri'] as $field) {
            if ($this->$field !== null) {
                $json[$field] = $this->$field;
            }
        }

        return $json;
    }
public function jsonSerialize()
    {
        $json = [];

        foreach (['code', 'message', 'description', 'uri'] as $field) {
            if ($this->$field !== null) {
                $json[$field] = $this->$field;
            }
        }

        return $json;
    }
public function jsonSerialize ( ) { $ json = [ ] ; foreach ( [ 'code' , 'message' , 'description' , 'uri' ] as $ field ) { if ( $ this -> $ field !== null ) { $ json [ $ field ] = $ this -> $ field ; } } return $ json ; }
Only include non-null fields in JSON.
Only include non - null fields in JSON .