public function forceEndDocument(): void
    {
        if (empty($this->stack)) {
            return;
        }

        $key = $this->keys;
        for ($i = $this->level - 1; $i > 0; --$i) {
            $value = array_pop($this->stack);
            //value
            $obj = array_pop($this->stack);
            if (!empty($key[$i])) {
                $obj[$key[$i]] = $value;
                $key[$i] = null;
            } else {
                $obj[] = $value;
            }
            if ($i > 1) {
                $this->stack[] = $obj;
            } else {
                $this->json = $obj;
            }
        }
    }
public function forceEndDocument(): void
    {
        if (empty($this->stack)) {
            return;
        }

        $key = $this->keys;
        for ($i = $this->level - 1; $i > 0; --$i) {
            $value = array_pop($this->stack);
            //value
            $obj = array_pop($this->stack);
            if (!empty($key[$i])) {
                $obj[$key[$i]] = $value;
                $key[$i] = null;
            } else {
                $obj[] = $value;
            }
            if ($i > 1) {
                $this->stack[] = $obj;
            } else {
                $this->json = $obj;
            }
        }
    }
public function forceEndDocument ( ) : void { if ( empty ( $ this -> stack ) ) { return ; } $ key = $ this -> keys ; for ( $ i = $ this -> level - 1 ; $ i > 0 ; -- $ i ) { $ value = array_pop ( $ this -> stack ) ; //value $ obj = array_pop ( $ this -> stack ) ; if ( ! empty ( $ key [ $ i ] ) ) { $ obj [ $ key [ $ i ] ] = $ value ; $ key [ $ i ] = null ; } else { $ obj [ ] = $ value ; } if ( $ i > 1 ) { $ this -> stack [ ] = $ obj ; } else { $ this -> json = $ obj ; } } }
Forcefully finish the document, end all objects and arrays
and set final object to the json property.
Forcefully finish the document end all objects and arrays and set final object to the json property .