mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
util: json: Improve handling and docs for adding JSON objects
The JSON structure constructor has an option to add JSON arrays to the constructed object. The description is inaccurate as it can add any json object even a dict. Change the docs to cover this option and reject adding NULL objects.
This commit is contained in:
parent
881c46595e
commit
81069ae3f5
@ -97,7 +97,8 @@ struct _virJSONParser {
|
||||
*
|
||||
* d: double precision floating point number
|
||||
* n: json null value
|
||||
* a: json array
|
||||
*
|
||||
* a: json object, must be non-NULL
|
||||
*
|
||||
* The value corresponds to the selected type.
|
||||
*
|
||||
@ -231,6 +232,14 @@ virJSONValueObjectCreateVArgs(virJSONValuePtr *obj, va_list args)
|
||||
|
||||
case 'a': {
|
||||
virJSONValuePtr val = va_arg(args, virJSONValuePtr);
|
||||
|
||||
if (!val) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not have null value"),
|
||||
key);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = virJSONValueObjectAppend(jargs, key, val);
|
||||
} break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user