I am not sure what environment you work with but I use pycharm and there are some issues with parse_json. It's mainly just indexing issues. For example, you mean to access "resolution" using data["resolution] but "resolution" is within "solver" so it has to be
data["solver"]["resolution"].
"solver":{
"resolution": 0.0085,
"frequency": {
"id": 1,
"val": 299792458
}
}
Another instance is trying to access multiple entries at once. You pass every obj in data['geometry']['circle'] to factory_circle. Factory circle then looks for the element in obj['id']. But passing every obj means you are indexing a string, obj is already being passed as 1, 1, [0,0], 0.1591.
"geometry": {
"circle": {
"id": 1,
"id_mat": 1,
"center": [0, 0],
"radius": 0.1591
}
}
for obj in data['geometry'][d]:
circ = factory_circle(obj)
vecObj.append(circ)
def factory_circle(dictObj):
""" Create a circle object from parsed json file
"""
idObj = dictObj['id']
It looks like the submission may change the formatting so the tabs for the functions are gone