Write to json