How To Write Json In Python By Using Json-Pickle Module-

Ex-

import jsonpickle
class Student:
    def __init__(self, st_no, st_name):
        self.st_no = st_no
        self.st_name = st_name

    def display(self):
        print('st_no:{}, st_name:{}'.format(self.st_no, self.st_name))

e = Student(101, 'Pankaj')
json_string = jsonpickle.encode(e)
print(json_string)
#### Write Json ####
with open('student.json', 'w') as f:
    f.write(json_string)

print("### Read the Json ####")
e2 = jsonpickle.decode(json_string)
e2.display()

Output-
{"py/object": "__main__.Student", "st_no": 101, "st_name": "Pankaj"}
### Read the Json ####
st_no:101, st_name:Pankaj
Menu