protected function createJsonResponse(array $data, array $config)
    {
        if (! \is_null($uses = $config['uses'] ?? null)) {
            $data = $data[$uses] ?? [];
        }

        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        $data = \array_map([$this, 'transformToArray'], $data);

        return function () use ($data, $config) {
            return \json_encode($data, $config['encoding'] ?? 0);
        };
    }
protected function createJsonResponse(array $data, array $config)
    {
        if (! \is_null($uses = $config['uses'] ?? null)) {
            $data = $data[$uses] ?? [];
        }

        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        $data = \array_map([$this, 'transformToArray'], $data);

        return function () use ($data, $config) {
            return \json_encode($data, $config['encoding'] ?? 0);
        };
    }
protected function createJsonResponse ( array $ data , array $ config ) { if ( ! \ is_null ( $ uses = $ config [ 'uses' ] ?? null ) ) { $ data = $ data [ $ uses ] ?? [ ] ; } if ( $ data instanceof Arrayable ) { $ data = $ data -> toArray ( ) ; } $ data = \ array_map ( [ $ this , 'transformToArray' ] , $ data ) ; return function ( ) use ( $ data , $ config ) { return \ json_encode ( $ data , $ config [ 'encoding' ] ?? 0 ) ; } ; }
Convert content to JSON.

@param  array  $data
@param  array  $config

@return \Closure
Convert content to JSON .