diff --git a/libobs/obs-data.c b/libobs/obs-data.c index 1179dab1e..b6bb3edd8 100644 --- a/libobs/obs-data.c +++ b/libobs/obs-data.c @@ -699,6 +699,18 @@ const char *obs_data_get_json(obs_data_t *data) return data->json; } +bool obs_data_save_json(obs_data_t *data, const char *file) +{ + const char *json = obs_data_get_json(data); + + if (json && *json) { + return os_quick_write_utf8_file(file, json, strlen(json), + false); + } + + return false; +} + static struct obs_data_item *get_item(struct obs_data *data, const char *name) { if (!data) return NULL; diff --git a/libobs/obs-data.h b/libobs/obs-data.h index cad13d2fc..c8d7c4c65 100644 --- a/libobs/obs-data.h +++ b/libobs/obs-data.h @@ -67,6 +67,7 @@ EXPORT void obs_data_addref(obs_data_t *data); EXPORT void obs_data_release(obs_data_t *data); EXPORT const char *obs_data_get_json(obs_data_t *data); +EXPORT bool obs_data_save_json(obs_data_t *data, const char *file); EXPORT void obs_data_apply(obs_data_t *target, obs_data_t *apply_data);