From: "Chang, Abner via groups.io" <abner.chang=amd.com@groups.io>
To: <devel@edk2.groups.io>
Cc: Nickle Wang <nicklew@nvidia.com>, Igor Kulchytskyy <igork@ami.com>
Subject: [edk2-devel] [RESEND PATCH] RedfishPkg/JsonLib: Add JSON delete object function
Date: Fri, 12 Jan 2024 11:23:35 +0800 [thread overview]
Message-ID: <20240112032335.736-1-abner.chang@amd.com> (raw)
From: Abner Chang <abner.chang@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
RedfishPkg/Include/Library/JsonLib.h | 17 +++++++++++++++++
RedfishPkg/Library/JsonLib/JsonLib.c | 24 ++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/RedfishPkg/Include/Library/JsonLib.h b/RedfishPkg/Include/Library/JsonLib.h
index 8f31d934148..ea252291a0e 100644
--- a/RedfishPkg/Include/Library/JsonLib.h
+++ b/RedfishPkg/Include/Library/JsonLib.h
@@ -656,6 +656,23 @@ JsonObjectSetValue (
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
is NULL or not a JSON array.
diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/JsonLib/JsonLib.c
index 6c3373d205c..b7be4d61766 100644
--- a/RedfishPkg/Library/JsonLib/JsonLib.c
+++ b/RedfishPkg/Library/JsonLib/JsonLib.c
@@ -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
is NULL or not a JSON array.
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113646): https://edk2.groups.io/g/devel/message/113646
Mute This Topic: https://groups.io/mt/103676885/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2024-01-12 3:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 3:23 Chang, Abner via groups.io [this message]
2024-01-16 3:06 ` [edk2-devel] [RESEND PATCH] RedfishPkg/JsonLib: Add JSON delete object function Nickle Wang via groups.io
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240112032335.736-1-abner.chang@amd.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox