I have a json object that I want to validate using Pydantic.
The problem I am facing is that:
1 - I don't know how many fields I will have in the JSON. The example below has 2 keys\fields: "225_5_99_0" and "225_5_99_1"
2 - I don't know the names of the fields in this case: It can be "225_5_99_0" or "226_0_0_0". I only know that they adhere to some convention.
3 - Some of the fields have keywords that are not valid for the model's field names, like the '*' key. This I might overcome by aliasing the field name to "asterisk".
Any ideas on the best way to tackle such a JSON?
{
"225_5_99_0": {
"*": {
"flag": "",
"group1": "225.5.99.0",
"group_type": "M",
"uptime": "0:11:23",
"iif": {"lo5": {
"flag": "R",
"uptime": "0:44:41"
}
},
"oil": {
"bun_1215": {
"flag": "",
"join_time": "00:03:14",
"uptime": "0:42:27"
},
"bun_1218": {
"flag": "",
"join_time": "00:02:44",
"uptime": "0:44:41"
}
},
"address": "100.100.100.100",
"rp": "*",
"source": "*",
"upstream": "Joined(00:00:19)"
}
},
"225_5_99_1": {
"*": {
"flag": "",
"group1": "225.5.99.0",
"group_type": "M",
"uptime": "0:11:23",
"iif": {"lo5": {
"flag": "R",
"uptime": "0:44:41"
}
},
"oil": {
"bun_1215": {
"flag": "",
"join_time": "00:03:14",
"uptime": "0:42:27"
},
"bun_1218": {
"flag": "",
"join_time": "00:02:44",
"uptime": "0:44:41"
}
},
"address": "100.100.100.100",
"rp": "*",
"source": "*",
"upstream": "Joined(00:00:19)"
}
},
}
}