Convert result to json and save to file