I have the following JSON object and I need to replace all None values with 0 (zero) within parameters keys.
{
"parameters": {
"x_pos": 0,
"y_pos": None,
"x_pos": 0,
"...": None,
},
}
I'm wondering if this can be done in a Pythonic way? And what that way is called (for example, List Comprehension). I think it might look something like this:
params = j_obj.get('parameters')
for param in params:
params[param] = params.get(param) if params.get(param) is not None else 0