I'm trying to figure out how I can encode my globals into a JSON format, I'm not even sure if it's possible. I'm using Python 2.7.8, and I've tried this from a few different approaches:
# Variables
value = "String" # String
value2 = 0 # Integer
value3 = True # Boolean
json.dumps({"key": value, "key2": value2, "key3": value3}, sort_keys=True, indent=4, separators=(',', ': '))
I also tried making it a string first (with and without the curly braces, with/without quotations on the string value etc.)
json_raw = '{"key": %s, "key2": %d, "key3": %s}' % (value, value2, value3)
json.dumps(json_raw, sort_keys=True, indent=4, separators=(',', ': '))
However, with each one of these attempts I get the error:
AttributeError: 'str' object has no attribute 'dumps'
Any ideas?