New to Python, trying to define a very simple class that will hold a few values, and then get it output into JSON notation.
import json
class Multiple:
def __init__(self, basis):
self.double = basis * 2
self.triple = basis * 3
self.quadruple = basis * 4
m = Multiple(100)
json.dumps(m)
I was hoping to see something like
{
"double":"200",
"triple":"300",
"quadruple":"400"
}
but instead get an error: "TypeError: <main.Multiple object at 0x0149A3F0> is not JSON serializable"