/* 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. */
CHAR8** JsonObjectGetKeys(IN EDKII_JSON_OBJECT JsonObj, OUT UINTN *KeyCount)
/* 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. */
CHAR8** JsonObjectGetKeys(IN EDKII_JSON_OBJECT JsonObj, OUT UINTN *KeyCount)
{
  UINTN             Index;
  CONST CHAR8       **KeyArray;
  CONST CHAR8       *Key;
  EDKII_JSON_VALUE  Value;
  if ((JsonObj == NULL) || (KeyCount == NULL)) {
    return NULL;
  }
  Index = 0;
  json_object_foreach (JsonObj, Key, Value) {
    Index++;
  }
  if (Index == 0) {
    *KeyCount = 0;
    return NULL;
  }
  *KeyCount = Index;
  KeyArray  = (CONST CHAR8 **)AllocateZeroPool (*KeyCount * sizeof (CHAR8 *));
  if (KeyArray == NULL) {
    return NULL;
  }
  Key   = NULL;
  Value = NULL;
  Index = 0;
  json_object_foreach ((json_t *)JsonObj, Key, Value) {
    KeyArray[Index] = Key;
    Index++;
  }
  return (CHAR8 **)KeyArray;
}