mirror of https://github.com/acidanthera/audk.git
RedfishPkg/JsonLib: Add JsonLoadString function
Add JsonLoadString function to load a NULL terminated-string JSON Signed-off-by: Abner Chang <abner.chang@hpe.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Nickle Wang <nickle.wang@hpe.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
This commit is contained in:
parent
739a506b18
commit
5d7b5cd105
|
@ -664,6 +664,27 @@ JsonDumpString (
|
||||||
IN UINTN Flags
|
IN UINTN Flags
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 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 CHAR8 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.
|
Load JSON from a buffer.
|
||||||
|
|
||||||
|
|
|
@ -819,6 +819,32 @@ JsonDumpString (
|
||||||
return json_dumps((json_t *)JsonValue, Flags);
|
return json_dumps((json_t *)JsonValue, Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 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 CHAR8 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.
|
Load JSON from a buffer.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue