[Solved] Python serialization error: NameError: name ‘JSON’ is not defined

Error content:

NameError: name ‘json’ is not defined

Prompt: JSON is not defined;

JSON used in serialization:

        rep = requests.post(url, data=json.dumps(data))

‘JSON’ is not defined Solution:

The error is generated due to not presence of JSON.

 JSON is a python library. To overcome this, you need to import JSON. You can import JSON directly.

import json

Also read | [Solved] Networkx Error: Attributeerror: ‘graph’ object has no attribute ‘node’

Default image
Ranjeet Singh Rawat