public function json($options = 0, $withDeferred = false)
    {
        $attributes = $this->attributes;
        if ($withDeferred) {
            foreach ($this->deferred as $attribute => $collection) {
                if (empty($collection)) {
                    continue; // Leave orriginal array with __deferred key
                }

                $attributes[$attribute] = [];
                foreach ($collection as $value) {
                    if (! empty($value->deferred)) {
                        $value->attributes = array_merge($value->attributes, $value->deferred);
                    }

                    if (is_a($value, 'Picqer\Financials\Exact\Model')) {
                        array_push($attributes[$attribute], $value->attributes);
                    } else {
                        array_push($attributes[$attribute], $value);
                    }
                }
            }
        }

        return json_encode($attributes, $options);
    }
public function json($options = 0, $withDeferred = false)
    {
        $attributes = $this->attributes;
        if ($withDeferred) {
            foreach ($this->deferred as $attribute => $collection) {
                if (empty($collection)) {
                    continue; // Leave orriginal array with __deferred key
                }

                $attributes[$attribute] = [];
                foreach ($collection as $value) {
                    if (! empty($value->deferred)) {
                        $value->attributes = array_merge($value->attributes, $value->deferred);
                    }

                    if (is_a($value, 'Picqer\Financials\Exact\Model')) {
                        array_push($attributes[$attribute], $value->attributes);
                    } else {
                        array_push($attributes[$attribute], $value);
                    }
                }
            }
        }

        return json_encode($attributes, $options);
    }
public function json ( $ options = 0 , $ withDeferred = false ) { $ attributes = $ this -> attributes ; if ( $ withDeferred ) { foreach ( $ this -> deferred as $ attribute => $ collection ) { if ( empty ( $ collection ) ) { continue ; // Leave orriginal array with __deferred key } $ attributes [ $ attribute ] = [ ] ; foreach ( $ collection as $ value ) { if ( ! empty ( $ value -> deferred ) ) { $ value -> attributes = array_merge ( $ value -> attributes , $ value -> deferred ) ; } if ( is_a ( $ value , 'Picqer\Financials\Exact\Model' ) ) { array_push ( $ attributes [ $ attribute ] , $ value -> attributes ) ; } else { array_push ( $ attributes [ $ attribute ] , $ value ) ; } } } } return json_encode ( $ attributes , $ options ) ; }
Return the JSON representation of the data.

@param int $options http://php.net/manual/en/json.constants.php

@return string
Return the JSON representation of the data .