Re: [edk2-devel] [RESEND PATCH] RedfishPkg/JsonLib: Add JSON delete object function

2024-01-15 Thread Nickle Wang via groups.io



Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, January 12, 2024 11:24 AM
> To: devel@edk2.groups.io
> Cc: Nickle Wang ; Igor Kulchytskyy 
> Subject: [RESEND PATCH] RedfishPkg/JsonLib: Add JSON delete object function
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> ---
>  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 (
>INEDKII_JSON_VALUE   Json
>);
> 
> +/**
> +  The function is used to delete a JSON key from the given JSON bject,
> +
> +  @param[in]   JsonObjThe provided JSON object.
> +  @param[in]   KeyThe key of the JSON value to be 
> deleted.
> +
> +  @retval  EFI_ABORTEDSome error occur and operation aborted.
> +  @retval  EFI_SUCCESSThe JSON value has been deleted from 
> this
> JSON object.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +JsonObjectDelete (
> +  INEDKII_JSON_OBJECT  JsonObj,
> +  INCONST 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]   JsonObjThe provided JSON object.
> +  @param[in]   KeyThe key of the JSON value to be 
> deleted.
> +
> +  @retval  EFI_ABORTEDSome error occur and operation aborted.
> +  @retval  EFI_SUCCESSThe JSON value has been deleted from 
> this
> JSON object.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +JsonObjectDelete (
> +  INEDKII_JSON_OBJECT  JsonObj,
> +  INCONST 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 (#113860): https://edk2.groups.io/g/devel/message/113860
Mute This Topic: https://groups.io/mt/103676885/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [RESEND PATCH] RedfishPkg/JsonLib: Add JSON delete object function

2024-01-11 Thread Chang, Abner via groups.io
From: Abner Chang 

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 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 (
   INEDKII_JSON_VALUE   Json
   );
 
+/**
+  The function is used to delete a JSON key from the given JSON bject,
+
+  @param[in]   JsonObjThe provided JSON object.
+  @param[in]   KeyThe key of the JSON value to be deleted.
+
+  @retval  EFI_ABORTEDSome error occur and operation aborted.
+  @retval  EFI_SUCCESSThe JSON value has been deleted from 
this JSON object.
+
+**/
+EFI_STATUS
+EFIAPI
+JsonObjectDelete (
+  INEDKII_JSON_OBJECT  JsonObj,
+  INCONST 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]   JsonObjThe provided JSON object.
+  @param[in]   KeyThe key of the JSON value to be deleted.
+
+  @retval  EFI_ABORTEDSome error occur and operation aborted.
+  @retval  EFI_SUCCESSThe JSON value has been deleted from 
this JSON object.
+
+**/
+EFI_STATUS
+EFIAPI
+JsonObjectDelete (
+  INEDKII_JSON_OBJECT  JsonObj,
+  INCONST 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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-