Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,16 @@ def analyze_json_file(file_obj):
|
|
61 |
# Assuming it's a file-like object, read the content as a string
|
62 |
file_str = file_obj.read().decode("utf-8")
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
audit_data = json.dumps(json_data, indent=2) # Convert JSON to a formatted string
|
66 |
return audit_data
|
67 |
|
|
|
61 |
# Assuming it's a file-like object, read the content as a string
|
62 |
file_str = file_obj.read().decode("utf-8")
|
63 |
|
64 |
+
# Check if the file content is empty
|
65 |
+
if not file_str.strip():
|
66 |
+
raise ValueError("Uploaded file is empty or not in JSON format.")
|
67 |
+
|
68 |
+
try:
|
69 |
+
# Attempt to parse JSON
|
70 |
+
json_data = json.loads(file_str)
|
71 |
+
except json.JSONDecodeError as e:
|
72 |
+
raise ValueError(f"Error decoding JSON: {str(e)}")
|
73 |
+
|
74 |
audit_data = json.dumps(json_data, indent=2) # Convert JSON to a formatted string
|
75 |
return audit_data
|
76 |
|