convert data to json format and keep in a file