Dataset Viewer issue for asaxena1990/Dummy_dataset
State: closed

### Link

_No response_

### Description

_No response_

### Owner

_No response_

Seems to be linked to the use of the undocumented `_resolve_features` method in the dataset viewer backend:

```
>>> from datasets import load_dataset
>>> dataset = load_dataset("asaxena1990/Dummy_dataset", name="asaxena1990--Dummy_dataset", split="train", streaming=True)
Using custom data configuration asaxena1990--Dummy_dataset-4a704ed7e5627563
>>> dataset._resolve_features()
Failed to read file 'https://huggingface.co/datasets/asaxena1990/Dummy_dataset/resolve/06885879a8bdd767d2d27695484fc6c83244617a/dummy_dataset_train.json' with error <class 'pyarrow.lib.ArrowInvalid'>: JSON parse error: Column() changed from object to array in row 0
Traceback (most recent call last):
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 109, in _generate_tables
    pa_table = paj.read_json(
  File "pyarrow/_json.pyx", line 246, in pyarrow._json.read_json
  File "pyarrow/error.pxi", line 143, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 99, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: JSON parse error: Column() changed from object to array in row 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 1261, in _resolve_features
    features = _infer_features_from_batch(self._head())
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 686, in _head
    return _examples_to_batch([x for key, x in islice(self._iter(), n)])
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 686, in <listcomp>
    return _examples_to_batch([x for key, x in islice(self._iter(), n)])
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 708, in _iter
    yield from ex_iterable
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 112, in __iter__
    yield from self.generate_examples_fn(**self.kwargs)
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 651, in wrapper
    for key, table in generate_tables_fn(**kwargs):
  File "/home/slesage/hf/datasets-server/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 137, in _generate_tables
    f"This JSON file contain the following fields: {str(list(dataset.keys()))}. "
AttributeError: 'list' object has no attribute 'keys'
```

Pinging @huggingface/datasets

Hi ! JSON files containing a list of object are not supported yet, you can use JSON Lines files instead in the meantime
```json
{"text": "can I know this?", "intent": "Know", "type": "Test"}
{"text": "can I know this?", "intent": "Know", "type": "Test"}
...
```

A JSON list of objects is supported as of version 2.5.0.