From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web09.27853.1612144503931068275 for ; Sun, 31 Jan 2021 17:55:04 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 01 Feb 2021 09:54:56 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Leif Lindholm'" , "'Nickle Wang'" , "'Michael D Kinney'" References: <20210129042004.20663-1-abner.chang@hpe.com> In-Reply-To: <20210129042004.20663-1-abner.chang@hpe.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIXSBSZWRmaXNoUGtnL0pzb25MaWI6IEFkZCBKc29uTG9hZFN0cmluZyBmdW5jdGlvbg==?= Date: Mon, 1 Feb 2021 09:55:01 +0800 Message-ID: <000301d6f83d$410553d0$c30ffb70$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKOJICVoFlV+qLptyfZMVad2VVNmajUMV1w Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Abner: What's the usage for this new API? Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: bounce+27952+70886+4905953+8761045@groups.io > =B4=FA=B1=ED Abner Chang > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA1=D4=C229=C8=D5 12:20 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Leif Lindholm ; Nickle Wang > ; Michael D Kinney > =D6=F7=CC=E2: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Add JsonLoadStrin= g 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..82ca4bad60 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 UTF8 encoded 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 usage. > + > + 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 UTF8 encoded string > to convert > + > + @retval Array JSON value or object JSON value, or NULL when any > error 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..00dedc1c60 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 UTF8 encoded 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 usage. > + > + 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 UTF8 encoded string > to convert > + > + @retval Array JSON value or object JSON value, or NULL when any > error 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 >=20 >=20 >=20 >=20 >=20