run-llama/llama_index · error · ValueError
JSON is invalid
Error message
JSON is invalid
What it means
Error "JSON is invalid" thrown in run-llama/llama_index.
Source
Thrown at llama-index-core/llama_index/core/node_parser/file/json.py:81
# Handle invalid JSON input here
return []
json_nodes = []
if isinstance(data, dict):
lines = [*self._depth_first_yield(data, 0, [])]
json_nodes.extend(
build_nodes_from_splits(["\n".join(lines)], node, id_func=self.id_func)
)
elif isinstance(data, list):
for json_object in data:
lines = [*self._depth_first_yield(json_object, 0, [])]
json_nodes.extend(
build_nodes_from_splits(
["\n".join(lines)], node, id_func=self.id_func
)
)
else:
raise ValueError("JSON is invalid")
return json_nodes
def _depth_first_yield(
self, json_data: Dict, levels_back: int, path: List[str]
) -> Generator[str, None, None]:
"""
Do depth first yield of all of the leaf nodes of a JSON.
Combines keys in the JSON tree using spaces.
If levels_back is set to 0, prints all levels.
"""
if isinstance(json_data, dict):
for key, value in json_data.items():
new_path = path[:]
new_path.append(key)View on GitHub (pinned to afd0fef371)
Solutions
- Validate the JSON input with json.loads before parsing; fix syntax errors in the source file.
- Ensure the file contains a single valid JSON document, not JSONL or truncated content.
When it happens
Trigger: Thrown at llama-index-core/llama_index/core/node_parser/file/json.py:81 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/dc50fed70f075387.
Report an issue: GitHub.