TianoCore EDK2 master
Loading...
Searching...
No Matches
JsonLib.c File Reference
#include <Uefi.h>
#include <Library/JsonLib.h>
#include <Library/BaseUcs2Utf8Lib.h>
#include <Library/MemoryAllocationLib.h>
#include "jansson.h"

Go to the source code of this file.

Functions

EDKII_JSON_VALUE EFIAPI JsonValueInitArray (VOID)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitObject (VOID)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitAsciiString (IN CONST CHAR8 *String)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitUnicodeString (IN CHAR16 *String)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitInteger (IN INT64 Value)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitBoolean (IN BOOLEAN Value)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitTrue (VOID)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitFalse (VOID)
 
EDKII_JSON_VALUE EFIAPI JsonValueInitNull (VOID)
 
VOID EFIAPI JsonValueFree (IN EDKII_JSON_VALUE Json)
 
EDKII_JSON_VALUE EFIAPI JsonValueClone (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsArray (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsObject (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsString (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsInteger (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsNumber (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsBoolean (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsTrue (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsFalse (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueIsNull (IN EDKII_JSON_VALUE Json)
 
EDKII_JSON_ARRAY EFIAPI JsonValueGetArray (IN EDKII_JSON_VALUE Json)
 
EDKII_JSON_OBJECT EFIAPI JsonValueGetObject (IN EDKII_JSON_VALUE Json)
 
CONST CHAR8 *EFIAPI JsonValueGetAsciiString (IN EDKII_JSON_VALUE Json)
 
CHAR16 *EFIAPI JsonValueGetUnicodeString (IN EDKII_JSON_VALUE Json)
 
INT64 EFIAPI JsonValueGetInteger (IN EDKII_JSON_VALUE Json)
 
BOOLEAN EFIAPI JsonValueGetBoolean (IN EDKII_JSON_VALUE Json)
 
CONST CHAR8 *EFIAPI JsonValueGetString (IN EDKII_JSON_VALUE Json)
 
UINTN EFIAPI JsonObjectSize (IN EDKII_JSON_OBJECT JsonObject)
 
EFI_STATUS EFIAPI JsonObjectClear (IN EDKII_JSON_OBJECT JsonObject)
 
CHAR8 ** JsonObjectGetKeys (IN EDKII_JSON_OBJECT JsonObj, OUT UINTN *KeyCount)
 
EDKII_JSON_VALUE EFIAPI JsonObjectGetValue (IN CONST EDKII_JSON_OBJECT JsonObj, IN CONST CHAR8 *Key)
 
EFI_STATUS EFIAPI JsonObjectSetValue (IN EDKII_JSON_OBJECT JsonObj, IN CONST CHAR8 *Key, IN EDKII_JSON_VALUE Json)
 
EFI_STATUS EFIAPI JsonObjectDelete (IN EDKII_JSON_OBJECT JsonObj, IN CONST CHAR8 *Key)
 
UINTN EFIAPI JsonArrayCount (IN EDKII_JSON_ARRAY JsonArray)
 
EDKII_JSON_VALUE EFIAPI JsonArrayGetValue (IN EDKII_JSON_ARRAY JsonArray, IN UINTN Index)
 
EFI_STATUS EFIAPI JsonArrayAppendValue (IN EDKII_JSON_ARRAY JsonArray, IN EDKII_JSON_VALUE Json)
 
EFI_STATUS EFIAPI JsonArrayRemoveValue (IN EDKII_JSON_ARRAY JsonArray, IN UINTN Index)
 
CHAR8 *EFIAPI JsonDumpString (IN EDKII_JSON_VALUE JsonValue, IN UINTN Flags)
 
EDKII_JSON_VALUE EFIAPI JsonLoadString (IN CONST CHAR8 *String, IN UINT64 Flags, IN EDKII_JSON_ERROR *Error)
 
EDKII_JSON_VALUE EFIAPI JsonLoadBuffer (IN CONST CHAR8 *Buffer, IN UINTN BufferLen, IN UINTN Flags, IN OUT EDKII_JSON_ERROR *Error)
 
VOID EFIAPI JsonDecreaseReference (IN EDKII_JSON_VALUE JsonValue)
 
EDKII_JSON_VALUE EFIAPI JsonIncreaseReference (IN EDKII_JSON_VALUE JsonValue)
 
VOID *EFIAPI JsonObjectIterator (IN EDKII_JSON_VALUE JsonValue)
 
EDKII_JSON_VALUE EFIAPI JsonObjectIteratorValue (IN VOID *Iterator)
 
VOID *EFIAPI JsonObjectIteratorNext (IN EDKII_JSON_VALUE JsonValue, IN VOID *Iterator)
 
CHAR8 *EFIAPI JsonObjectIteratorKey (IN VOID *Iterator)
 
VOID *EFIAPI JsonObjectKeyToIterator (IN CHAR8 *Key)
 
EDKII_JSON_TYPE EFIAPI JsonGetType (IN EDKII_JSON_VALUE JsonValue)
 
EFI_STATUS EFIAPI JsonLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

volatile UINT32 hashtable_seed
 

Detailed Description

APIs for JSON operations. The fuctions provided by this library are the wrapper to native open source jansson library. See below document for the API reference. https://jansson.readthedocs.io/en/2.13/apiref.html

Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2021 Hewlett Packard Enterprise Development LP
Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file JsonLib.c.

Function Documentation

◆ JsonArrayAppendValue()

EFI_STATUS EFIAPI JsonArrayAppendValue ( IN EDKII_JSON_ARRAY  JsonArray,
IN EDKII_JSON_VALUE  Json 
)

The function is used to append a JSON value to the end of the JSON array, and grow the size of array by 1. The reference count of this value will be increased by 1.

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]JsonArrayThe provided JSON object.
[in]JsonThe JSON value to append.
Return values
EFI_ABORTEDSome error occur and operation aborted.
EFI_SUCCESSJSON value has been appended to the end of the JSON array.

Definition at line 896 of file JsonLib.c.

◆ JsonArrayCount()

UINTN EFIAPI JsonArrayCount ( IN EDKII_JSON_ARRAY  JsonArray)

The function is used to get the number of elements in a JSON array. Returns or 0 if JsonArray is NULL or not a JSON array.

Parameters
[in]JsonArrayThe provided JSON array.
Return values
Returnthe number of elements in this JSON array or 0.

Definition at line 848 of file JsonLib.c.

◆ JsonArrayGetValue()

EDKII_JSON_VALUE EFIAPI JsonArrayGetValue ( IN EDKII_JSON_ARRAY  JsonArray,
IN UINTN  Index 
)

The function is used to return the JSON value in the array at position index. The valid range for this index is from 0 to the return value of JsonArrayCount() minus 1.

It only returns a reference to this value and any changes on this value will impact the original JSON object. If that is not expected, please call JsonValueClone() to clone it to use.

If this array is NULL or not a JSON array, or if index is out of range, NULL will be returned.

Parameters
[in]JsonArrayThe provided JSON Array.
Return values
Returnthe JSON value located in the Index position or NULL if JsonArray is not an array or no items in the array.

Definition at line 873 of file JsonLib.c.

◆ JsonArrayRemoveValue()

EFI_STATUS EFIAPI JsonArrayRemoveValue ( IN EDKII_JSON_ARRAY  JsonArray,
IN UINTN  Index 
)

The function is used to remove a JSON value at position index, shifting the elements after index one position towards the start of the array. The reference count of this value will be decreased by 1.

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]JsonArrayThe provided JSON array.
[in]IndexThe Index position before removal.
Return values
EFI_ABORTEDSome error occur and operation aborted.
EFI_SUCCESSThe JSON array has been removed at position index.

Definition at line 924 of file JsonLib.c.

◆ JsonDecreaseReference()

VOID EFIAPI JsonDecreaseReference ( IN EDKII_JSON_VALUE  JsonValue)

The reference count is used to track whether a value is still in use or not. When a value is created, it's reference count is set to 1. when the value is no longer needed, the reference count is decremented. When the reference count drops to zero, there are no references left and the value can be destroyed.

This function decrement the reference count of EDKII_JSON_VALUE. As soon as a call to json_decref() drops the reference count to zero, the value is destroyed and it can no longer be used.

Parameters
[in]JsonValueJSON value

Definition at line 1046 of file JsonLib.c.

◆ JsonDumpString()

CHAR8 *EFIAPI JsonDumpString ( IN EDKII_JSON_VALUE  JsonValue,
IN UINTN  Flags 
)

Dump JSON to a buffer.

Parameters
[in]JsonValueThe provided JSON value.
[in]FlagsThe Index position before removal. The value could be the combination of below flags.
  • EDKII_JSON_INDENT(n)
  • EDKII_JSON_COMPACT
  • EDKII_JSON_ENSURE_ASCII
  • EDKII_JSON_SORT_KEYS
  • EDKII_JSON_PRESERVE_ORDER
  • EDKII_JSON_ENCODE_ANY
  • EDKII_JSON_ESCAPE_SLASH
  • EDKII_JSON_REAL_PRECISION(n)
  • EDKII_JSON_EMBED See below URI for the JSON encoding flags reference. https://jansson.readthedocs.io/en/2.13/apiref.html#encoding
Return values
CHAR8* Dump fail if NULL returned, otherwise the buffer contain JSON payload in ASCII string. The return value must be freed by the caller using FreePool().

Definition at line 960 of file JsonLib.c.

◆ JsonGetType()

EDKII_JSON_TYPE EFIAPI JsonGetType ( IN EDKII_JSON_VALUE  JsonValue)

Returns the json type of this json value.

Parameters
[in]JsonValueJSON value
Return values
JSONtype returned

Definition at line 1161 of file JsonLib.c.

◆ JsonIncreaseReference()

EDKII_JSON_VALUE EFIAPI JsonIncreaseReference ( IN EDKII_JSON_VALUE  JsonValue)

The reference count is used to track whether a value is still in use or not. When a value is created, it's reference count is set to 1. If a reference to a value is kept (e.g. a value is stored somewhere for later use), its reference count is incremented.

This function increment the reference count of json if it's not NULL. Returns EDKII_JSON_VALUE.

Parameters
[in]JsonValueJSON value
Return values
EDKII_JSON_VALUEof itself

Definition at line 1067 of file JsonLib.c.

◆ JsonLibConstructor()

EFI_STATUS EFIAPI JsonLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

JSON Library constructor.

Parameters
ImageHandleThe image handle.
SystemTableThe system table.
Return values
EFI_SUCCESSProtocol listener is registered successfully.

Definition at line 1179 of file JsonLib.c.

◆ JsonLoadBuffer()

EDKII_JSON_VALUE EFIAPI JsonLoadBuffer ( IN CONST CHAR8 *  Buffer,
IN UINTN  BufferLen,
IN UINTN  Flags,
IN OUT EDKII_JSON_ERROR Error 
)

Load JSON from a buffer.

Parameters
[in]BufferBuffier to the JSON payload
[in]BufferLenLength of the buffer
[in]FlagsFlag of loading JSON buffer, the value could be the combination of below flags.
[in,out]ErrorPointer EDKII_JSON_ERROR structure
Return values
EDKII_JSON_VALUENULL means fail to load JSON payload.

Definition at line 1021 of file JsonLib.c.

◆ JsonLoadString()

EDKII_JSON_VALUE EFIAPI JsonLoadString ( IN CONST CHAR8 *  String,
IN UINT64  Flags,
IN EDKII_JSON_ERROR Error 
)

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 supported by UEFI.

Caller needs to cleanup the root value by calling JsonValueFree().

Parameters
[in]StringThe NULL terminated CHAR8 string to convert.
[in]FlagsFlags for loading JSON string.
[in]ErrorReturned error status.
Return values
ArrayJSON value or object JSON value, or NULL when any error occurs.

Definition at line 991 of file JsonLib.c.

◆ JsonObjectClear()

EFI_STATUS EFIAPI JsonObjectClear ( IN EDKII_JSON_OBJECT  JsonObject)

The function removes all elements from object. Returns 0 on success and -1 if object is not a JSON object. The reference count of all removed values are decremented.

Parameters
[in]JsonObjectThe provided JSON object.
Return values
EFI_ABORTEDSome error occur and operation aborted.
EFI_SUCCESSJSON value has been appended to the end of the JSON array.

Definition at line 689 of file JsonLib.c.

◆ JsonObjectDelete()

EFI_STATUS EFIAPI JsonObjectDelete ( IN EDKII_JSON_OBJECT  JsonObj,
IN CONST CHAR8 *  Key 
)

The function is used to delete a JSON key from the given JSON bject

Parameters
[in]JsonObjThe provided JSON object.
[in]KeyThe key of the JSON value to be deleted.
Return values
EFI_ABORTEDSome error occur and operation aborted.
EFI_SUCCESSThe JSON value has been deleted from this JSON object.

Definition at line 825 of file JsonLib.c.

◆ JsonObjectGetKeys()

CHAR8 ** JsonObjectGetKeys ( IN EDKII_JSON_OBJECT  JsonObj,
OUT UINTN KeyCount 
)

The function is used to enumerate all keys in a JSON object.

Caller should be responsible to free the returned key array reference using FreePool(). But contained keys are read only and must not be modified or freed.

Parameters
[in]JsonObjThe provided JSON object for enumeration.
[out]KeyCountThe count of keys in this JSON object.
Return values
Returnan array of the enumerated keys in this JSON object or NULL if JsonObj is not an JSON object, key count is zero or on other errors.

Definition at line 714 of file JsonLib.c.

◆ JsonObjectGetValue()

EDKII_JSON_VALUE EFIAPI JsonObjectGetValue ( IN CONST EDKII_JSON_OBJECT  JsonObj,
IN CONST CHAR8 *  Key 
)

The function is used to get a JSON value corresponding to the input key from a JSON object.

It only returns a reference to this value and any changes on this value will impact the original JSON object. If that is not expected, please call JsonValueClone() to clone it to use.

Input key must be a valid NULL terminated UTF8 encoded string. NULL will be returned when Key-Value is not found in this JSON object.

Parameters
[in]JsonObjThe provided JSON object.
[in]KeyThe key of the JSON value to be retrieved.
Return values
Returnthe corresponding JSON value to key, or NULL on error.

Definition at line 772 of file JsonLib.c.

◆ JsonObjectIterator()

VOID *EFIAPI JsonObjectIterator ( IN EDKII_JSON_VALUE  JsonValue)

Returns an opaque iterator which can be used to iterate over all key-value pairs in object, or NULL if object is empty.

Parameters
[in]JsonValueJSON value
Return values
Iteratorpointer

Definition at line 1083 of file JsonLib.c.

◆ JsonObjectIteratorKey()

CHAR8 *EFIAPI JsonObjectIteratorKey ( IN VOID *  Iterator)

Returns the key of iterator pointing.

Parameters
[in]IteratorIterator pointer
Return values
Key

Definition at line 1131 of file JsonLib.c.

◆ JsonObjectIteratorNext()

VOID *EFIAPI JsonObjectIteratorNext ( IN EDKII_JSON_VALUE  JsonValue,
IN VOID *  Iterator 
)

Returns an iterator pointing to the next key-value pair in object after iter, or NULL if the whole object has been iterated through.

Parameters
[in]JsonValueJSON value
[in]IteratorIterator pointer
Return values
Iteratorpointer

Definition at line 1115 of file JsonLib.c.

◆ JsonObjectIteratorValue()

EDKII_JSON_VALUE EFIAPI JsonObjectIteratorValue ( IN VOID *  Iterator)

Extract the associated value from iterator.

Parameters
[in]IteratorIterator pointer
Return values
EDKII_JSON_VALUE

Definition at line 1098 of file JsonLib.c.

◆ JsonObjectKeyToIterator()

VOID *EFIAPI JsonObjectKeyToIterator ( IN CHAR8 *  Key)

Returns the pointer of iterator by key.

Parameters
[in]KeyThe key of interator pointer.
Return values
Pointerto interator

Definition at line 1146 of file JsonLib.c.

◆ JsonObjectSetValue()

EFI_STATUS EFIAPI JsonObjectSetValue ( IN EDKII_JSON_OBJECT  JsonObj,
IN CONST CHAR8 *  Key,
IN EDKII_JSON_VALUE  Json 
)

The function is used to set a JSON value corresponding to the input key from a JSON object, and the reference count of this value will be increased by 1.

Input key must be a valid NULL terminated UTF8 encoded string. If there already is a value for this key, this key will be assigned to the new JSON value. The old JSON value will be removed from this object and thus its' reference count will be decreased by 1.

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]JsonObjThe provided JSON object.
[in]KeyThe key of the JSON value to be set.
[in]JsonThe JSON value to set to this JSON object mapped by key.
Return values
EFI_ABORTEDSome error occur and operation aborted.
EFI_SUCCESSThe JSON value has been set to this JSON object.

Definition at line 800 of file JsonLib.c.

◆ JsonObjectSize()

UINTN EFIAPI JsonObjectSize ( IN EDKII_JSON_OBJECT  JsonObject)

The function is used to get the number of elements in a JSON object, or 0 if it is NULL or not a JSON object.

Parameters
[in]JsonObjectThe provided JSON object.
Return values
Returnthe number of elements in this JSON object or 0.

Definition at line 670 of file JsonLib.c.

◆ JsonValueClone()

EDKII_JSON_VALUE EFIAPI JsonValueClone ( IN EDKII_JSON_VALUE  Json)

The function is used to create a fresh copy of a JSON value, and all child values are deep copied in a recursive fashion. It should be called when this JSON value might be modified in later use, but the original still wants to be used in somewhere else.

Reference counts of the returned root JSON value and all child values will be set to 1, and caller needs to cleanup the root value by calling JsonValueFree().

Note: Since this function performs a copy from bottom to up, too many calls may cause some performance issues, user should avoid unnecessary calls to this function unless it is really needed.

Parameters
[in]JsonThe JSON value to be cloned.
Return values
Returnthe cloned JSON value, or NULL on error.

Definition at line 295 of file JsonLib.c.

◆ JsonValueFree()

VOID EFIAPI JsonValueFree ( IN EDKII_JSON_VALUE  Json)

The function is used to decrease the reference count of a JSON value by one, and once this reference count drops to zero, the value is destroyed and it can no longer be used. If this destroyed value is object type or array type, reference counts for all containing JSON values will be decreased by 1. Boolean JSON value and NULL JSON value won't be destroyed since they are static values kept in memory.

Reference Count Strategy: BaseJsonLib uses this strategy to track whether a value is still in use or not. When a value is created, it's reference count is set to 1. If a reference to a value is kept for use, its reference count is incremented, and when the value is no longer needed, the reference count is decremented. When the reference count drops to zero, there are no references left, and the value can be destroyed.

The given JSON value maybe NULL and not causing any problem. Just output the debug message to inform caller the NULL value is passed in.

Parameters
[in]JsonThe JSON value to be freed. json_decref may return without any changes if Json is NULL.

Definition at line 269 of file JsonLib.c.

◆ JsonValueGetArray()

EDKII_JSON_ARRAY EFIAPI JsonValueGetArray ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated array in an array type JSON value.

Any changes to the returned array will impact the original JSON value.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated array in JSON value or NULL.

Definition at line 485 of file JsonLib.c.

◆ JsonValueGetAsciiString()

CONST CHAR8 *EFIAPI JsonValueGetAsciiString ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated Ascii string in a string type JSON value.

Any changes to the returned string will impact the original JSON value.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated Ascii string in JSON value or NULL.

Definition at line 531 of file JsonLib.c.

◆ JsonValueGetBoolean()

BOOLEAN EFIAPI JsonValueGetBoolean ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated boolean in a boolean type JSON value.

The input JSON value should not be NULL or contain no JSON boolean, otherwise it will ASSERT() and return FALSE.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated value of JSON boolean.

Definition at line 628 of file JsonLib.c.

◆ JsonValueGetInteger()

INT64 EFIAPI JsonValueGetInteger ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated integer in a integer type JSON value.

The input JSON value should not be NULL or contain no JSON integer, otherwise it will ASSERT() and return 0.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated integer in JSON value.

Definition at line 603 of file JsonLib.c.

◆ JsonValueGetObject()

EDKII_JSON_OBJECT EFIAPI JsonValueGetObject ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated object in an object type JSON value.

Any changes to the returned object will impact the original JSON value.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated object in JSON value or NULL.

Definition at line 508 of file JsonLib.c.

◆ JsonValueGetString()

CONST CHAR8 *EFIAPI JsonValueGetString ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated string in a string type JSON value.

Any changes to the returned string will impact the original JSON value.

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated Ascii string in JSON value or NULL on errors.

Definition at line 652 of file JsonLib.c.

◆ JsonValueGetUnicodeString()

CHAR16 *EFIAPI JsonValueGetUnicodeString ( IN EDKII_JSON_VALUE  Json)

The function is used to retrieve the associated Unicode string in a string type JSON value.

Caller can do any changes to the returned string without any impact to the original JSON value, and caller needs to free the returned string using FreePool().

Parameters
[in]JsonThe provided JSON value.
Return values
Returnthe associated Unicode string in JSON value or NULL.

Definition at line 568 of file JsonLib.c.

◆ JsonValueInitArray()

EDKII_JSON_VALUE EFIAPI JsonValueInitArray ( VOID  )

The function is used to initialize a JSON value which contains a new JSON array, or NULL on error. Initially, the array is empty.

The reference count of this value will be set to 1, and caller needs to cleanup the value by calling JsonValueFree().

More details for reference count strategy can refer to the API description for JsonValueFree().

Return values
Thecreated JSON value which contains a JSON array or NULL if initial a JSON array is failed.

Definition at line 39 of file JsonLib.c.

◆ JsonValueInitAsciiString()

EDKII_JSON_VALUE EFIAPI JsonValueInitAsciiString ( IN CONST CHAR8 *  String)

The function is used to initialize a JSON value which contains a new JSON string, or NULL on error.

The input string must be NULL terminated Ascii format, non-Ascii characters will be processed as an error. Unicode characters can also be represented by Ascii string as the format: \u + 4 hexadecimal digits, like \u3E5A, or \u003F.

The reference count of this value will be set to 1, and caller needs to cleanup the value by calling JsonValueFree().

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]StringThe Ascii string to initialize to JSON value
Return values
Thecreated JSON value which contains a JSON string or NULL. Select a Getter API for a specific encoding format.

Definition at line 89 of file JsonLib.c.

◆ JsonValueInitBoolean()

EDKII_JSON_VALUE EFIAPI JsonValueInitBoolean ( IN BOOLEAN  Value)

The function is used to initialize a JSON value which contains a new JSON boolean, or NULL on error.

Boolean JSON value is kept as static value, and no need to do any cleanup work.

Parameters
[in]ValueThe boolean value to initialize.
Return values
Thecreated JSON value which contains a JSON boolean or NULL.

Definition at line 186 of file JsonLib.c.

◆ JsonValueInitFalse()

EDKII_JSON_VALUE EFIAPI JsonValueInitFalse ( VOID  )

The function is used to initialize a JSON value which contains a FALSE JSON value, or NULL on error.

NULL JSON value is kept as static value, and no need to do any cleanup work.

Return values
Thecreated JSON FALSE value.

Definition at line 222 of file JsonLib.c.

◆ JsonValueInitInteger()

EDKII_JSON_VALUE EFIAPI JsonValueInitInteger ( IN INT64  Value)

The function is used to initialize a JSON value which contains a new JSON integer, or NULL on error.

The reference count of this value will be set to 1, and caller needs to cleanup the value by calling JsonValueFree().

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]ValueThe integer to initialize to JSON value
Return values
Thecreated JSON value which contains a JSON integer or NULL.

Definition at line 166 of file JsonLib.c.

◆ JsonValueInitNull()

EDKII_JSON_VALUE EFIAPI JsonValueInitNull ( VOID  )

The function is used to initialize a JSON value which contains a new JSON NULL, or NULL on error.

NULL JSON value is kept as static value, and no need to do any cleanup work.

Return values
Thecreated NULL JSON value.

Definition at line 240 of file JsonLib.c.

◆ JsonValueInitObject()

EDKII_JSON_VALUE EFIAPI JsonValueInitObject ( VOID  )

The function is used to initialize a JSON value which contains a new JSON object, or NULL on error. Initially, the object is empty.

The reference count of this value will be set to 1, and caller needs to cleanup the value by calling JsonValueFree().

More details for reference count strategy can refer to the API description for JsonValueFree().

Return values
Thecreated JSON value which contains a JSON object or NULL if initial a JSON object is failed.

Definition at line 61 of file JsonLib.c.

◆ JsonValueInitTrue()

EDKII_JSON_VALUE EFIAPI JsonValueInitTrue ( VOID  )

The function is used to initialize a JSON value which contains a TRUE JSON value, or NULL on error.

NULL JSON value is kept as static value, and no need to do any cleanup work.

Return values
Thecreated JSON TRUE value.

Definition at line 204 of file JsonLib.c.

◆ JsonValueInitUnicodeString()

EDKII_JSON_VALUE EFIAPI JsonValueInitUnicodeString ( IN CHAR16 *  String)

The function is used to initialize a JSON value which contains a new JSON string, or NULL on error.

The input must be a NULL terminated UCS2 format Unicode string.

The reference count of this value will be set to 1, and caller needs to cleanup the value by calling JsonValueFree().

More details for reference count strategy can refer to the API description for JsonValueFree().

Parameters
[in]StringThe Unicode string to initialize to JSON value
Return values
Thecreated JSON value which contains a JSON string or NULL. Select a Getter API for a specific encoding format.

Definition at line 130 of file JsonLib.c.

◆ JsonValueIsArray()

BOOLEAN EFIAPI JsonValueIsArray ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON array.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a JSON array.
FALSEThe JSON value doesn't contain a JSON array.

Definition at line 313 of file JsonLib.c.

◆ JsonValueIsBoolean()

BOOLEAN EFIAPI JsonValueIsBoolean ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON boolean.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a JSON boolean.
FALSEThe JSON value doesn't contain a JSON boolean.

Definition at line 404 of file JsonLib.c.

◆ JsonValueIsFalse()

BOOLEAN EFIAPI JsonValueIsFalse ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a FALSE value.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a FALSE value.
FALSEThe JSON value doesn't contain a FALSE value.

Definition at line 444 of file JsonLib.c.

◆ JsonValueIsInteger()

BOOLEAN EFIAPI JsonValueIsInteger ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON integer.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value is contains JSON integer.
FALSEThe JSON value doesn't contain a JSON integer.

Definition at line 368 of file JsonLib.c.

◆ JsonValueIsNull()

BOOLEAN EFIAPI JsonValueIsNull ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON NULL.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a JSON NULL.
FALSEThe JSON value doesn't contain a JSON NULL.

Definition at line 466 of file JsonLib.c.

◆ JsonValueIsNumber()

BOOLEAN EFIAPI JsonValueIsNumber ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON number.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value is contains JSON number.
FALSEThe JSON value doesn't contain a JSON number.

Definition at line 386 of file JsonLib.c.

◆ JsonValueIsObject()

BOOLEAN EFIAPI JsonValueIsObject ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a JSON object.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a JSON object.
FALSEThe JSON value doesn't contain a JSON object.

Definition at line 331 of file JsonLib.c.

◆ JsonValueIsString()

BOOLEAN EFIAPI JsonValueIsString ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON Value contains a string, Ascii or Unicode format is not differentiated.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a JSON string.
FALSEThe JSON value doesn't contain a JSON string.

Definition at line 350 of file JsonLib.c.

◆ JsonValueIsTrue()

BOOLEAN EFIAPI JsonValueIsTrue ( IN EDKII_JSON_VALUE  Json)

The function is used to return if the provided JSON value contains a TRUE value.

Parameters
[in]JsonThe provided JSON value.
Return values
TRUEThe JSON value contains a TRUE value.
FALSEThe JSON value doesn't contain a TRUE value.

Definition at line 422 of file JsonLib.c.