write into json file in right way