RedfishPkg/JsonLib: Add JSON delete object function
To support the deletion on a specified JSON object. Signed-off-by: Abner Chang <abner.chang@amd.com> Cc: Nickle Wang <nicklew@nvidia.com> Cc: Igor Kulchytskyy <igork@ami.com> Reviewed-by: Nickle Wang <nicklew@nvidia.com>
This commit is contained in:
committed by
mergify[bot]
parent
8f6d343ae6
commit
9971b99461
@@ -656,6 +656,23 @@ JsonObjectSetValue (
|
|||||||
IN EDKII_JSON_VALUE Json
|
IN EDKII_JSON_VALUE Json
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
The function is used to delete a JSON key from the given JSON bject,
|
||||||
|
|
||||||
|
@param[in] JsonObj The provided JSON object.
|
||||||
|
@param[in] Key The key of the JSON value to be deleted.
|
||||||
|
|
||||||
|
@retval EFI_ABORTED Some error occur and operation aborted.
|
||||||
|
@retval EFI_SUCCESS The JSON value has been deleted from this JSON object.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
JsonObjectDelete (
|
||||||
|
IN EDKII_JSON_OBJECT JsonObj,
|
||||||
|
IN CONST CHAR8 *Key
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray
|
The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray
|
||||||
is NULL or not a JSON array.
|
is NULL or not a JSON array.
|
||||||
|
@@ -810,6 +810,30 @@ JsonObjectSetValue (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
The function is used to delete a JSON key from the given JSON bject
|
||||||
|
|
||||||
|
@param[in] JsonObj The provided JSON object.
|
||||||
|
@param[in] Key The key of the JSON value to be deleted.
|
||||||
|
|
||||||
|
@retval EFI_ABORTED Some error occur and operation aborted.
|
||||||
|
@retval EFI_SUCCESS The JSON value has been deleted from this JSON object.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
JsonObjectDelete (
|
||||||
|
IN EDKII_JSON_OBJECT JsonObj,
|
||||||
|
IN CONST CHAR8 *Key
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (json_object_del ((json_t *)JsonObj, (const char *)Key) != 0) {
|
||||||
|
return EFI_ABORTED;
|
||||||
|
} else {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray
|
The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray
|
||||||
is NULL or not a JSON array.
|
is NULL or not a JSON array.
|
||||||
|
Reference in New Issue
Block a user