From nobody Wed May 15 20:21:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+113645+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1705029447495326.9000887195657; Thu, 11 Jan 2024 19:17:27 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=r5avm0yWz7EwuoTp9CC+s22zAaTzAfTsBkLJgY32PXs=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1705029447; v=1; b=cj6T1SU8ullIvLts8v+HpKav50l6tGBrw39OWlnkuPsTGkdFO4JyFxqkQfFFSMQ6n4uVLml9 pMxwzP3Fydv9/ORh7NaJeFeffA1ge+Ai+2IzE3xWVc4whBjYJhCACZjeniSjYzHmbSWfbKvgUy0 PwxRLVoDXsPAneJ7BrKqhcXQ= X-Received: by 127.0.0.2 with SMTP id CSkBYY1788612xFmOndinQ91; Thu, 11 Jan 2024 19:17:27 -0800 X-Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.61]) by mx.groups.io with SMTP id smtpd.web10.11490.1705029446190485888 for ; Thu, 11 Jan 2024 19:17:26 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VUEpQZB/CEFpYKtjTbXZq3qm1MdMeMN2WMQ1lUIQN+Oq7tXL7O8C82NSZr5Bjb+3oQ+UmAbMW22vgP9O+ClbV2bj5NcBjYaWlI9BUiU1QjosCqTAJVLXuQ0KNsup0mVP9NtQsO775LldMsh3LE8ox4ru4VmrTWdX2lMvWDZQ6YPkmBZ4MdELnlLWCgjVquezANJF9sZjJmpsnbAR7PunGwdFPeD17Ok7rLhIzQNuR0jdKr6GpJ3dkm0Z+1ZuA21Ylq6W+7nBKrbCB/rEOYt1zPdUxlD79pCAuT0TkxiKnbfyHY7QrYPGxmCgWaj5aS1CNNFDKOcplE7UODkrRRzbKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T18XREBl9XQHhu1hKjhrZzUzAgd83tUDlPDp2jcKQe4=; b=esimx+R7L3LXv/kWAYH7idzUUSLxkjkuWQtxomHH7cqwbefTV6v1qiLaFaW68/kkLMxMfPhUDEAwKxQn6q2S/thgHvUN7H9vc0EuSH+yKEdVX1LAuZlN/4k+7DdUgWPWkjdinpLEY24triHqhIzLqOqHOCw++1Btp3EnBtfUBe7CUOD8gZhcxR+vyt7ZfRRCOD6prNzyYKMfTvA3TWwb2ZDoEqXPy8vvyFH0pRi+EHZJejuHaPbDg486HJtAcOBgOQQiKF1vGJRKjLYkc1ODhHS1jNQpdxiemMAYDAtDB+VhrrHG/8A/F15kZt/X/O5XJt1bLKfrDqGcNjbyk7OqNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from MN2PR16CA0010.namprd16.prod.outlook.com (2603:10b6:208:134::23) by IA0PR12MB7554.namprd12.prod.outlook.com (2603:10b6:208:43e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.17; Fri, 12 Jan 2024 03:17:23 +0000 X-Received: from BL02EPF0001A0FD.namprd03.prod.outlook.com (2603:10b6:208:134:cafe::d9) by MN2PR16CA0010.outlook.office365.com (2603:10b6:208:134::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.18 via Frontend Transport; Fri, 12 Jan 2024 03:17:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+113645+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL02EPF0001A0FD.mail.protection.outlook.com (10.167.242.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.14 via Frontend Transport; Fri, 12 Jan 2024 03:17:23 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Thu, 11 Jan 2024 21:17:21 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [edk2-platforms][PATCH] RedfishPkg/JsonLib: Add JSON delete object function Date: Fri, 12 Jan 2024 11:16:35 +0800 Message-ID: <20240112031635.713-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A0FD:EE_|IA0PR12MB7554:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bd025d8-b0ce-48ff-1fe7-08dc131cfef8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Zv0L4UspWY+i8pRH80qczUGak1NEsWZ+pQKxezN0b3sF1VyaV1EHkfUs5z66FqwuIlwJ9DPBTb4kRk36XKcgtfCACBnEIFFtt7737nvsZlcMEsHouV8g72QF2fVRiZWU+E9V+O64Oe/rIUv98OfRA/PE6OvAlU3hL24vXjGrXZ5MSVSSp2yphKqL3B9sWKVDeaPdA7k6QbJO9leo++kXAudPj17JUxWi1XnrMDSkVMpGAjTmDu/RYtgDZrGpu/mZIYjGpRQu5ivDaXc9G8gYzdvowNAFuQYs4agO750qvCmJTrOb6d0xVPrYaXW4FWxy/LIQ7dOAVARBEuzrRyfxVtMwIQLrzi0X5sSXZuBBYXtsMz0RFBGq6JFB1V8/3Ct3xetbEcSwATPs71vTH2UcBLmWoPfg5a7mp3/NY6j7tDUtensncO902Zn4/ZyAwGZw80rfHIeqFYLgmvw3UvEFeqaJS5uARa8pvs+AzPJay8khfc4B95bVdd5K6cvbJbI8GRMdnSFpJa5EFK/7+fK6PNHzCGmlokhVRWaL95wqE0WhX5DEwHZCZ2RYeWVYWz6dGNOv12qHNU4xWVjM1AiG5JXLzcjSaJzXZg0eihhDuJGYBlyE7SZJOGSovqBlCuajWC3HAPFKjJs5n8AjoTQZkxf19YnBxcy+HJAQxcruilMOASUhAwmnjAM4FJ/Rxfbm8tM9dNBTNom66KiAQs74+DkA8een36eNTQomvY7fA6Ma/fvTlro6Du7b5/kp6d8kM3TNyiB6kjk7khnpcO0mEg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2024 03:17:23.6985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4bd025d8-b0ce-48ff-1fe7-08dc131cfef8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A0FD.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7554 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6iln86w1cpLBUt2eAZgpQh72x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1705029448569100001 Content-Type: text/plain; charset="utf-8" From: Abner Chang Add JSON delete object function to remove JSON object from the given JSON paylaod. 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/Libr= ary/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 ); =20 +/** + 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 dele= ted. + + @retval EFI_ABORTED Some error occur and operation abort= ed. + @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. Retu= rns or 0 if JsonArray is NULL or not a JSON array. diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/Json= Lib/JsonLib.c index 6c3373d205c..b7be4d61766 100644 --- a/RedfishPkg/Library/JsonLib/JsonLib.c +++ b/RedfishPkg/Library/JsonLib/JsonLib.c @@ -810,6 +810,30 @@ JsonObjectSetValue ( } } =20 +/** + 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 dele= ted. + + @retval EFI_ABORTED Some error occur and operation abort= ed. + @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) !=3D 0) { + return EFI_ABORTED; + } else { + return EFI_SUCCESS; + } +} + /** The function is used to get the number of elements in a JSON array. Retu= rns or 0 if JsonArray is NULL or not a JSON array. --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113645): https://edk2.groups.io/g/devel/message/113645 Mute This Topic: https://groups.io/mt/103676803/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-