def simplejson(thing): if (type(thing) is list or type(thing) is tuple): return '[' + ', '.join([simplejson(x) for x in thing]) + ']' elif (type(thing) is dict): return '{' + ', '.join(["%s: %s" %(simplejson(str(x)), simplejson(y)) for x,y in thing.iteritems()]) + '}' elif (type(thing) is int): return str(thing) else: return '"' + str(thing).replace("\"", "\\\"").replace("\n","\\n") + '"'