fork download
  1. import json
  2.  
  3. class Example:
  4. foo = ""
  5. bar = 0
  6.  
  7. def __init__(self, foo, bar):
  8. self.foo = foo
  9. self.bar = bar
  10.  
  11. value = Example("I'm a string with \"quotes\" in it.", 42)
  12. print(f"const obj = {json.dumps(value.__dict__)};")
  13. num = 42
  14. print(f"const num = {json.dumps(num)};")
Success #stdin #stdout 0.02s 9640KB
stdin
Standard input is empty
stdout
const obj = {"foo": "I'm a string with \"quotes\" in it.", "bar": 42};
const num = 42;