in lib/parson.c [1778:1798]
JSON_Status json_serialize_to_file(const JSON_Value *value, const char *filename) {
JSON_Status return_code = JSONSuccess;
FILE *fp = NULL;
char *serialized_string = json_serialize_to_string(value);
if (serialized_string == NULL) {
return JSONFailure;
}
fp = fopen(filename, "w");
if (fp == NULL) {
json_free_serialized_string(serialized_string);
return JSONFailure;
}
if (fputs(serialized_string, fp) == EOF) {
return_code = JSONFailure;
}
if (fclose(fp) == EOF) {
return_code = JSONFailure;
}
json_free_serialized_string(serialized_string);
return return_code;
}