Fixed to use to_json function instead of json module, then removed Python >= 2.6
 - thanks to rjollos, jun66j5