1import json
2
3class Laptop:
4 name = 'My Laptop'
5 processor = 'Intel Core'
6
7#create object
8laptop1 = Laptop()
9laptop1.name = 'Dell Alienware'
10laptop1.processor = 'Intel Core i7'
11
12#convert to JSON string
13jsonStr = json.dumps(laptop1.__dict__)
14
15#print json string
16print(jsonStr)