mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qobject: New qdict_from_jsonf_nofail()
Many uses of qobject_from_jsonf() convert JSON objects. Create new convenience function qdict_from_jsonf_nofail() that includes the conversion to QDict. The next few commits will put it to use. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180703085358.13941-22-armbru@redhat.com>
This commit is contained in:
parent
cab5ad86b4
commit
a193352ff9
2 changed files with 20 additions and 0 deletions
|
@ -76,6 +76,24 @@ QObject *qobject_from_jsonf(const char *string, ...)
|
|||
return obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse @string as JSON object with %-escapes interpolated.
|
||||
* Abort on error. Do not use with untrusted @string.
|
||||
* Return the resulting QDict. It is never null.
|
||||
*/
|
||||
QDict *qdict_from_jsonf_nofail(const char *string, ...)
|
||||
{
|
||||
QDict *obj;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, string);
|
||||
obj = qobject_to(QDict, qobject_from_jsonv(string, &ap, &error_abort));
|
||||
va_end(ap);
|
||||
|
||||
assert(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
typedef struct ToJsonIterState
|
||||
{
|
||||
int indent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue