convert class object to json python
jsonStr = json.dumps(myobject.__dict__)import json
class Laptop:
name = 'My Laptop'
processor = 'Intel Core'
#create object
laptop1 = Laptop()
laptop1.name = 'Dell Alienware'
laptop1.processor = 'Intel Core i7'
#convert to JSON string
jsonStr = json.dumps(laptop1.__dict__)
#print json string
print(jsonStr)
Also in JavaScript:
- javascript round to 2 digits
- print code in js stackoverflow
- how to add data modal target attribute in jquery
- convert decimal to binary javascript
- jquery label with text
- jquery get next element
- greater than x but less than y es6
- activar funcion js con id
- three.js create sphere
- checking if a character is an alphabet in js
- three js get size of object
- react native create button
- hide and show in angular 8
- Parallax.js wrapper for react
- add array to array javascript
- particle js
- onfocus jquery
- binary to ascii javascript
- electron send message from renderer to main
- select option value jquery
- check if date equal js
- js outputting data
- node red admin password setting
- this.handler.handle is not a function