bugfix in writing json file.