[Django]-How can I remove null keys with values from JSON object in python?

2👍

If you are looking to delete a key from the dict a similar question has been answered here:
How can I remove a key from a Python dictionary?

You are assigning industries to the item you just popped from the dictionary.

Solution A

To fix this you must not assign the popped item to industries.

Just remove the industries = as follows:

Before

industries = industries.pop("null", None)

After

industries.pop("null", None)

This should give you the result you desire.

Solution B

If that didn’t work try using del as follows:

del industries["null"]

EDIT

It seems like you forgot the quotations marks on the None key in the object, that seems to have solved your problem.

👤Liam

Leave a comment