Spaces:
Sleeping
Sleeping
File size: 677 Bytes
26e3944 56cf7e3 26e3944 56cf7e3 26e3944 56cf7e3 26e3944 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import json
text = """```json
[
["Sunday", "Thursday"],
["two millions", "one million"],
["north", "east"],
["Japan", "UK"],
["Sunday", "Thursday"]
]
```
"""
def read_json(json_string) -> list[list[str]]:
try:
entities = json.loads(json_string)
# Remove duplicates pair of entities
unique_data = []
for inner_list in entities:
if inner_list not in unique_data:
unique_data.append(inner_list)
return unique_data
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
return []
print(read_json(text.replace("```json", "").replace("```", ""))) |