repl.it
@acwoss/

UnlawfulOutstandingEngineer

Python

No description

fork
loading
Files
  • main.py
main.py
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
28
29
30
31
import json

def json_loads_with_missing_commas(data):
    try:
        return json.loads(data)
    except json.decoder.JSONDecodeError as error:
        if error.msg == "Expecting ',' delimiter":
            # Cria um novo JSON adicionando a vírgula onde deu erro
            data = error.doc[:error.pos] + ',' + error.doc[error.pos:]
            return json_loads_with_missing_commas(data)
        raise error

data = """
{
    "array": [{
        "id": "123"
        "anotherObject": {
            "name": "something"
        }
        "address": {
            "street": "Dreamland"
            "anotherArray": [
                [3 3]
                [3 3]
            ]
        }
    }]
}
"""

print(json_loads_with_missing_commas(data))
Fetching token
?