libobs: Add obs_data_get_last_json()

Helper function to return the last generated json string for this
object.
This commit is contained in:
jp9000 2021-04-23 12:38:50 -07:00
parent 00fdec2493
commit 74c2379eba
3 changed files with 19 additions and 0 deletions

View file

@ -67,6 +67,19 @@ General Functions
.. function:: const char *obs_data_get_json(obs_data_t *data)
Generates a new json string. The string allocation is stored within
the data object itself, and does not need to be manually freed.
:return: Json string for this object
---------------------
.. function:: const char *obs_data_get_last_json(obs_data_t *data)
Returns the last json string generated for this data object. Does not
generate a new string. Use :c:func:`obs_data_get_json()` to generate
a json string first.
:return: Json string for this object
---------------------

View file

@ -742,6 +742,11 @@ const char *obs_data_get_json(obs_data_t *data)
return data->json;
}
const char *obs_data_get_last_json(obs_data_t *data)
{
return data ? data->json : NULL;
}
bool obs_data_save_json(obs_data_t *data, const char *file)
{
const char *json = obs_data_get_json(data);

View file

@ -70,6 +70,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 const char *obs_data_get_last_json(obs_data_t *data);
EXPORT bool obs_data_save_json(obs_data_t *data, const char *file);
EXPORT bool obs_data_save_json_safe(obs_data_t *data, const char *file,
const char *temp_ext,