public function toArray($data, $rootKey = null)
    {
        $data = json_decode($data, true);

        if ($rootKey === null) {
            return $data;
        }

        if (!isset($data[$rootKey])) {
            return [];
        }

        return $data[$rootKey];
    }
public function toArray($data, $rootKey = null)
    {
        $data = json_decode($data, true);

        if ($rootKey === null) {
            return $data;
        }

        if (!isset($data[$rootKey])) {
            return [];
        }

        return $data[$rootKey];
    }
public function toArray ( $ data , $ rootKey = null ) { $ data = json_decode ( $ data , true ) ; if ( $ rootKey === null ) { return $ data ; } if ( ! isset ( $ data [ $ rootKey ] ) ) { return [ ] ; } return $ data [ $ rootKey ] ; }
Converts data from JSON to an associative array.

@param  string $data Source data to convert, as a JSON string
@param string $rootKey
@return array  Converted data
Converts data from JSON to an associative array .