summaryrefslogtreecommitdiffstats
path: root/RedfishPkg/Library/JsonLib/JsonLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'RedfishPkg/Library/JsonLib/JsonLib.c')
-rw-r--r--RedfishPkg/Library/JsonLib/JsonLib.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/JsonLib/JsonLib.c
index 69f2455c00..9b758b9402 100644
--- a/RedfishPkg/Library/JsonLib/JsonLib.c
+++ b/RedfishPkg/Library/JsonLib/JsonLib.c
@@ -28,7 +28,7 @@
More details for reference count strategy can refer to the API description for JsonValueFree().
- @retval The created JSON value which contains a JSON array or NULL if intial a JSON array
+ @retval The created JSON value which contains a JSON array or NULL if initial a JSON array
is failed.
**/
@@ -50,7 +50,7 @@ JsonValueInitArray (
More details for reference count strategy can refer to the API description for JsonValueFree().
- @retval The created JSON value which contains a JSON object or NULL if intial a JSON object
+ @retval The created JSON value which contains a JSON object or NULL if initial a JSON object
is failed.
**/
@@ -673,6 +673,29 @@ JsonObjectSize (
}
/**
+ The function removes all elements from object. Returns 0 on success and -1 if object is not
+ a JSON object. The reference count of all removed values are decremented.
+
+ @param[in] JsonObject The provided JSON object.
+
+ @retval EFI_ABORTED Some error occur and operation aborted.
+ @retval EFI_SUCCESS JSON value has been appended to the end of the JSON array.
+
+**/
+EFI_STATUS
+EFIAPI
+JsonObjectClear (
+ IN EDKII_JSON_OBJECT JsonObject
+ )
+{
+ if (json_object_clear ((json_t *)JsonObject) != 0) {
+ return EFI_ABORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
The function is used to enumerate all keys in a JSON object.
Caller should be responsible to free the returned key array reference using
@@ -864,7 +887,7 @@ JsonArrayAppendValue (
More details for reference count strategy can refer to the API description for JsonValueFree().
@param[in] JsonArray The provided JSON array.
- @param[in] Index The Index position before removement.
+ @param[in] Index The Index position before removal.
@retval EFI_ABORTED Some error occur and operation aborted.
@retval EFI_SUCCESS The JSON array has been removed at position index.
@@ -888,7 +911,7 @@ JsonArrayRemoveValue (
Dump JSON to a buffer.
@param[in] JsonValue The provided JSON value.
- @param[in] Flags The Index position before removement. The value
+ @param[in] Flags The Index position before removal. The value
could be the combination of below flags.
- EDKII_JSON_INDENT(n)
- EDKII_JSON_COMPACT
@@ -903,7 +926,7 @@ JsonArrayRemoveValue (
https://jansson.readthedocs.io/en/2.13/apiref.html#encoding
@retval CHAR8 * Dump fail if NULL returned, otherwise the buffer
- contain JSON paylaod in ASCII string. The return
+ contain JSON payload in ASCII string. The return
value must be freed by the caller using FreePool().
**/
CHAR8 *
@@ -926,7 +949,7 @@ JsonDumpString (
value. Only object and array represented strings can be converted successfully,
since they are the only valid root values of a JSON text for UEFI usage.
- Real number and number with exponent part are not supportted by UEFI.
+ Real number and number with exponent part are not supported by UEFI.
Caller needs to cleanup the root value by calling JsonValueFree().
@@ -951,7 +974,7 @@ JsonLoadString (
/**
Load JSON from a buffer.
- @param[in] Buffer Bufffer to the JSON payload
+ @param[in] Buffer Buffier to the JSON payload
@param[in] BufferLen Length of the buffer
@param[in] Flags Flag of loading JSON buffer, the value
could be the combination of below flags.
@@ -986,7 +1009,7 @@ JsonLoadBuffer (
When the reference count drops to zero, there are no references left and the
value can be destroyed.
- This funciton decrement the reference count of EDKII_JSON_VALUE. As soon as
+ This function decrement the reference count of EDKII_JSON_VALUE. As soon as
a call to json_decref() drops the reference count to zero, the value is
destroyed and it can no longer be used.