Issue #161: add a json_object_to_fd() function.

This commit is contained in:
Eric Haszlakiewicz
2017-06-18 18:44:45 +00:00
parent 23e064ad29
commit e8e574fbe4
4 changed files with 96 additions and 31 deletions

View File

@@ -67,7 +67,18 @@ extern int json_object_to_file(const char *filename, struct json_object *obj);
extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
/**
* Return the last error from json_object_to_file{,_ext} or
* Convert the json_object to a string and write it to the file descriptor.
* Handles partial writes and will keep writing until done, or an error
* occurs.
*
* @param flags flags to pass to json_object_to_json_string_ext()
* @return -1 if something fails. See json_util_get_last_err() for details.
*/
extern int json_object_to_fd(int fd, struct json_object *obj, int flags);
/**
* Return the last error from json_object_to_file{,_ext},
* json_object_to_fd() or
* json_object_from_{file,fd}, or NULL if there is none.
*/
const char *json_util_get_last_err(void);