Fixed broken API (there were duplicate json_encode calls which broke the output)