summaryrefslogtreecommitdiff
path: root/RedfishPkg/Library
diff options
context:
space:
mode:
authorAbner Chang <abner.chang@hpe.com>2021-01-29 11:46:53 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-02-24 08:27:09 +0000
commit5d7b5cd10569f3098c8a51c10a94bf2f6cc45bf5 (patch)
tree2f92fc98ddbd83258c6f830bb703499e44d22645 /RedfishPkg/Library
parent739a506b18c4f694b8d5d2f3424a329c45d737ba (diff)
downloadedk2-5d7b5cd10569f3098c8a51c10a94bf2f6cc45bf5.zip
edk2-5d7b5cd10569f3098c8a51c10a94bf2f6cc45bf5.tar.gz
edk2-5d7b5cd10569f3098c8a51c10a94bf2f6cc45bf5.tar.bz2
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>
Diffstat (limited to 'RedfishPkg/Library')
-rw-r--r--RedfishPkg/Library/JsonLib/JsonLib.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/JsonLib/JsonLib.c
index 34ff381..3693299 100644
--- a/RedfishPkg/Library/JsonLib/JsonLib.c
+++ b/RedfishPkg/Library/JsonLib/JsonLib.c
@@ -820,6 +820,32 @@ JsonDumpString (
}
/**
+ 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.
@param[in] Buffer Bufffer to the JSON payload