sys.stdout.write('    "datapoints":[\n')
for tuple in rrdMetric[2]:
    if tuple[0] is not None:
        if not firstDP:
            sys.stdout.write(',\n')
firstDP = False
sys.stdout.write('      [')
sys.stdout.write(str(tuple[0]))
sys.stdout.write(',')
sys.stdout.write(str(time))
sys.stdout.write(']')
time = time + step
sys.stdout.write('\n    ]\n  }')
printMetric()
Convert .rrd file to json in python