Tranfer dict to json and output to file also.