From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.6968.1614066584827100115 for ; Mon, 22 Feb 2021 23:49:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=SMMUEH1z; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=06885caa36=nickle.wang@hpe.com) Received: from pps.filterd (m0134421.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N7mEFE023710; Tue, 23 Feb 2021 07:49:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=QiXiAOE3Ve7uOBAum4hMBr7Rw5XbedyJg7zN6Qxm9L4=; b=SMMUEH1zsxsncei8DZF3LuUCTngmXep4sn3puuyHU4i+UUm9HcLRHldddWPgOpd5L6mA B1qzgureDE4VEn+ly7nh0SL+hinnXBE2ewlTWatrs3M4AnoX0p2UsLlQfjJxgzbjmyTA 92H9mItCFVxvrBku5Js/y9sf0jTgmAV/86j7/lJ0icetxGYF6JCRrlaCuqNGb5rgccNf VsJJ77RRHoCmUwYOf7bMw41tQGTvNPsmcGADTkWroy8BCo4E0tTxxS3xLiVDfYuTuonz rsivTg2mEoFw8f+5kycFkoyOgVtSuSdAJTZvpBd+Agh7Mjzjie10P4XG5FZuvbHkTvxF 9A== Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0b-002e3701.pphosted.com with ESMTP id 36ubt0qh1c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 07:49:44 +0000 Received: from G4W9121.americas.hpqcorp.net (g4w9121.houston.hp.com [16.210.21.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3426.houston.hpe.com (Postfix) with ESMTPS id 8B9D24E; Tue, 23 Feb 2021 07:49:43 +0000 (UTC) Received: from G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) by G4W9121.americas.hpqcorp.net (2002:10d2:1510::10d2:1510) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Feb 2021 07:49:43 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (15.241.52.13) by G4W9119.americas.hpqcorp.net (16.210.20.214) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 23 Feb 2021 07:49:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evQKB1s0/MRhyTuidhngBT8O6ktHCD3w3G5WkuczY9Yx5vJLtNoOfCE1vSouWNSeWWVXCpog872FDEgdfpJKbylLriPXP4SeHHl0c1uva2llZm3yBsrEk00HLBI2ZsEGEfhDmlxrIgLPw3ioND164/OlaSm5x2CXBbnufIjmXGnUYDWXmbxxAOatkmGqAXSFbUHvwwAuHgF8c7+LngKeB97N93Fk1F6agwD8dkXJouOZNYgJ9JO4UQiKoUe1sV/VGDT0Gsg/WrL/q5vZolcre8kI2TJe/PpR74/lxGpvxFofFFea2WgaHI2dedUy0P1qMQ6mSt1z4x5wkfO9DQcUAQ== 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-SenderADCheck; bh=QiXiAOE3Ve7uOBAum4hMBr7Rw5XbedyJg7zN6Qxm9L4=; b=akBQ5ADgK+zwhXamfVkiZyEmbh1cjXK6r8B/PKmhMlPHzvI78KThFk6FIEHLbQgyz0elpn/2tnLLWU0HdJiTh+pDnNJKNeARyyIwlXheTxUKdombNqRpb1AYypVigQIZmAtHfpZwPEnvY6hRW4nwf/gVmznOdqzY/drwtx5yjoUC/T36m5LhDjdYad7LO2kDFhC+ZkFKDEVuRem6spD4+ygIuIKhjiiE0Y23eOsCbQ7xKl6SF0CPpEJUVmRuxjX1dph/Es2RQGmpbPMc7wfLJ86YGGm7ubQDfDhL7eoNyXMEUEdPnJfdDe82EGY1k4ctbuQkbRhbZAMIb+vZk9Crcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::7) by DF4PR8401MB1196.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7613::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.29; Tue, 23 Feb 2021 07:49:41 +0000 Received: from DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c1ae:b73d:dbaa:9a6e]) by DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c1ae:b73d:dbaa:9a6e%9]) with mapi id 15.20.3868.033; Tue, 23 Feb 2021 07:49:41 +0000 From: "Nickle Wang" To: "Chang, Abner (HPS SW/FW Technologist)" , "devel@edk2.groups.io" CC: Leif Lindholm , Michael D Kinney Subject: Re: [PATCH v2] RedfishPkg/JsonLib: Add JsonLoadString function Thread-Topic: [PATCH v2] RedfishPkg/JsonLib: Add JsonLoadString function Thread-Index: AQHXBarOQCvTWxjapUGiuwQ6jQub3aplZVVw Date: Tue, 23 Feb 2021 07:49:41 +0000 Message-ID: References: <20210218031219.16966-1-abner.chang@hpe.com> In-Reply-To: <20210218031219.16966-1-abner.chang@hpe.com> Accept-Language: zh-TW, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: hpe.com; dkim=none (message not signed) header.d=none;hpe.com; dmarc=none action=none header.from=hpe.com; x-originating-ip: [16.242.247.139] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 169f4cb2-5edf-4701-4212-08d8d7cf93f5 x-ms-traffictypediagnostic: DF4PR8401MB1196: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YRxciei6y9nzrI7blRjxinZO13Xk6SMURU4haXsrvLKduGvRUmo8Zxq7P8BMkD/BpICnPxVFI4ZKUaNIdeKkxVWYoOPf19suxiPuXmAxeLWkzSyHsftUb/DRrvWoEMxEn19CcX52xxFzBzT4qnJsw3mfr6CZ8PqoDVWu1Ynq7D/mG+ngSt/DPyNaLM2jczdk/zVZFenlXaKpcf44/vDXGHIniWxMI4x/S+KFVmeKJ8VoVr0UKPOA8we/jZmkNYHPom8YJR582G6Qdv2Bc376NNOrZgmNum0Wubjlp2I2G9PtVJUvmuyOiVgJBvc35v2G/QCP3QaaubDa+JDnn4ee4o2yfNUMHkkWTPrXafuTWLSdLLuHw09DHEnRqRRzcgFy/sE1zsuIXQ5vJBDBmiXgTo/f62Ok02JDh7bYGYtvudHU/0WpW30PuE5pok3Z5sN3uiQJXVLi5iAjMr79UIfgeDeQxg9RQW28CzwzE9gYqqGNqH10BTz3cMD3UG9G/9EY3hAE8nveE38/JesXPYtx7A== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(136003)(366004)(396003)(376002)(346002)(39860400002)(52536014)(316002)(4326008)(2906002)(54906003)(83380400001)(76116006)(66476007)(66556008)(8936002)(64756008)(6506007)(86362001)(66946007)(66446008)(186003)(8676002)(110136005)(71200400001)(5660300002)(7696005)(26005)(9686003)(478600001)(53546011)(55016002)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?RHCae+KPeu6HgQiBRDQqqKxssOa6DLOfsi/+zSGhW0oONHcOsN5+sckZf1Jt?= =?us-ascii?Q?cy6p56LSNmxB3v4p0+1eSLUJFZLXPo2Djj1w3Lex88fV0gM87tjmRf9Gotbr?= =?us-ascii?Q?s+ECOBn2H4QomNFxX57azNZMWm0ZZggPKv/Pxa69QTd0bCpcQ39aeRD9CvBV?= =?us-ascii?Q?6d9MkvgGhFstd/HBPh8fcPFm4HVkVgtf9GjFNYL5QHW9BWG2FoJ6Qto/qnVg?= =?us-ascii?Q?whZNj9hA3Z7rnqs2nNOk20QDeod41usOK35hOetwL/Sv5Mg7sMFxKh2EeEYa?= =?us-ascii?Q?Kf5xKq5/h4sT+zbh0t7ISv4VUQjSN1eFvulsdLEoMsmPPIkk3nbSzZnSEuVo?= =?us-ascii?Q?diC+JupZQW2j2+C9hzyVaKd0QInLXCbubi+kYeS7hRZFecKExCSWN+Zj7Yaj?= =?us-ascii?Q?U2rN7XDfvs4308W9sp2uLAYnmmTdFAaW5caEsQvCK+NoxI96CUMe+hT/zbVC?= =?us-ascii?Q?VwFyhrSVEziIXxdk0QhRverv4IRYyPRfGrrRbaH6Y8v0liEtmsbAjcowGbyV?= =?us-ascii?Q?sVJv1xJXeqMJTnbI8+2R+2FQYk2slpEs08ljo24j7ptLmMpvyv/RNSQOT/xY?= =?us-ascii?Q?7nAaNGZaKf5ojBZhK2/cVrcDZgq8ETAnodFqkOUTKzvCIWQH1W+k4c88teNK?= =?us-ascii?Q?YJtrd8z7p6fIWCC2/FQRDiFSkCdNBZf/VqctTy7XpYSITh9EOwMwlN/p4WTp?= =?us-ascii?Q?vwzNlDVjvN/M8E10uREnxg2bjgWxmn8PHtozky7tFscBrYbLLozrqP3vmNM+?= =?us-ascii?Q?qlziBqgkGbIqXQc5b75sdsGxxeNzCXFJhHX0SHtnOzJYBF3sEjZPsB8O9cPl?= =?us-ascii?Q?SdizYhh8fpqO2IFoVIjxp3zw30WrhE51nVZwAEs1ukeT6zBIPnmyFOYDZOvw?= =?us-ascii?Q?uDLfFkWAC+llSdjTlMs0e2QcQBT48JrRokci5zCsj0lv37hgGeikR1nDlHrq?= =?us-ascii?Q?MhTDICrcTefBzl431RUw6/fFDqySJeLpc5N8CiWhnpUx47jBVrpdaTgykhjI?= =?us-ascii?Q?qU6cw4SNW4pcS0xmZbavq5KjroVVc27Y8v2EKf4uzcOZ1q9H2nk0wkzN1Bse?= =?us-ascii?Q?/U+bEthf/p8UB4jIaKgJaT9xgJ+hlO+fAOVOTb9gbEbw5LWT4Cujo4sd3YL7?= =?us-ascii?Q?LSdeSqq+i42r8jW3O7W0xaUUsmMV4OqikD/3zT9zSS8G4EccpMWXHuFRRq0f?= =?us-ascii?Q?17bwkuNWV8GjbPA9YskKa9wWiHcSQRc73Ac6WJLhfBvp8Xlc0+r+jbUIZy3e?= =?us-ascii?Q?056S6JVE5/cmjyrrf7prgLgW1RV/PaOCpacYH6wq5KnB8I3TiqKUuMMA/kS0?= =?us-ascii?Q?peX2RHCrQwukE3mr6Z7dzGWP?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 169f4cb2-5edf-4701-4212-08d8d7cf93f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 07:49:41.2761 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ZFUf2bgtppkRgXxvvv79f8LZltnwPJCYz4qedaDz8UE7dCCYE+Pg3lx1QXFKrva6XBTclApAcOCDQjerr1U3Zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1196 X-OriginatorOrg: hpe.com X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-23_02:2021-02-22,2021-02-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 impostorscore=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230065 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for addressing my comment. The function header looks good to me now. Reviewed-by: Nickle Wang Thanks, Nickle > -----Original Message----- > From: Chang, Abner (HPS SW/FW Technologist) > Sent: Thursday, February 18, 2021 11:12 AM > To: devel@edk2.groups.io > Cc: Leif Lindholm ; Wang, Nickle (HPS SW) > ; Michael D Kinney > Subject: [PATCH v2] RedfishPkg/JsonLib: Add JsonLoadString function >=20 > Add JsonLoadString function to load a NULL terminated-string JSON >=20 > Signed-off-by: Abner Chang >=20 > Cc: Leif Lindholm > Cc: Nickle Wang > Cc: Michael D Kinney > --- > RedfishPkg/Include/Library/JsonLib.h | 21 +++++++++++++++++++++ > RedfishPkg/Library/JsonLib/JsonLib.c | 26 ++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+) >=20 > diff --git a/RedfishPkg/Include/Library/JsonLib.h > b/RedfishPkg/Include/Library/JsonLib.h > index 3c10f67d27..8a30c5250b 100644 > --- a/RedfishPkg/Include/Library/JsonLib.h > +++ b/RedfishPkg/Include/Library/JsonLib.h > @@ -664,6 +664,27 @@ JsonDumpString ( > IN UINTN Flags > ); >=20 > +/** > + Convert a string to JSON object. > + The function is used to convert a NULL terminated CHAR8 string to a > +JSON > + 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 usag= e. > + > + Real number and number with exponent part are not supportted by UEFI. > + > + Caller needs to cleanup the root value by calling JsonValueFree(). > + > + @param[in] String The NULL terminated CHAR8 string to convert= . > + > + @retval Array JSON value or object JSON value, or NULL when any e= rror > occurs. > + > +**/ > +EDKII_JSON_VALUE > +EFIAPI > +JsonLoadString ( > + IN CONST CHAR8* String > + ); > + > /** > Load JSON from a buffer. >=20 > diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c > b/RedfishPkg/Library/JsonLib/JsonLib.c > index 34ff381aee..3693299afb 100644 > --- a/RedfishPkg/Library/JsonLib/JsonLib.c > +++ b/RedfishPkg/Library/JsonLib/JsonLib.c > @@ -819,6 +819,32 @@ JsonDumpString ( > return json_dumps((json_t *)JsonValue, Flags); } >=20 > +/** > + Convert a string to JSON object. > + The function is used to convert a NULL terminated CHAR8 string to a > +JSON > + 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 usag= e. > + > + Real number and number with exponent part are not supportted by UEFI. > + > + Caller needs to cleanup the root value by calling JsonValueFree(). > + > + @param[in] String The NULL terminated CHAR8 string to convert= . > + > + @retval Array JSON value or object JSON value, or NULL when any e= rror > occurs. > + > +**/ > +EDKII_JSON_VALUE > +EFIAPI > +JsonLoadString ( > + IN CONST CHAR8* String > + ) > +{ > + json_error_t JsonError; > + > + return (EDKII_JSON_VALUE) json_loads ((const char *)String, 0, > +&JsonError); } > + > /** > Load JSON from a buffer. >=20 > -- > 2.17.1