In this post, we will see how to resolve How to remove json element with empty quotes?
Question:
In thepython3
code below I read all the objects
in the json
then loop through the elements
in the json
. If I only search for the id is not None
that element and the null value are removed. However when I add the or
statement to remove the id is not ""
the entire file is printed with neither of the id
in the or statement removed. Being new to python
I am not sure what I am doing wrong. Thank you :).file
id
were changed:Best Answer:
If the value is None, then the
is not ""
part will be true.If the value is an empty string, then the
is not None
part will be true.And if the value is anything else, then both parts will be true.
As @Pranav commented, you want to use
and
here, not or
.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review