Map In Array

If TArray of TMaps is all what you need, then you can easily do this like so:

Header:

TArray<TMap<FString, FString>> Variable;

And here’s the usage:

Variable.Add(TMap<FString, FString>());
Variable[0].Add("Key 1", "Value 1");
Variable[0].Add("Key 2", "Value 2");
Variable[0].Add("Key 3", "Value 3");
Variable[0].Add("Key 4", "Value 4");

Variable.Add(TMap<FString, FString>());
Variable[1].Add("Key 5", "Value 5");
Variable[1].Add("Key 6", "Value 6");

Keep in mind, that, TMaps aren’t supported by UPROPERTY macros so if you’ll add that, the code won’t compile.

If you want to get data from this variable in blueprint, you can do that using this function:

Header:

UFUNCTION(BlueprintPure, Category = "Default")
bool GetValue(const FString& InKey, FString& OutValue, int InRow = -1);

Implementation:

bool AGameStateMultiplayer::GetValue(const FString& InKey, FString& OutValue, int InRow /*= -1*/)
{
     // -1 means we want to search through every row
     if (InRow == -1)
     {
         // Iterating over every row
         for (auto Map : Variable)
         {
             if (Map.Contains(InKey))
             {
                 OutValue = Map[InKey];
                 return true;
             }
         }
     }
     else
     {
         // If row index is valid
         if (InRow > 0 && Variable.Num() > InRow)
         {
             if (Variable[InRow].Contains(InKey))
             {
                 OutValue = Variable[InRow][InKey];
                 return true;
             }
         }
      }
  
      return false;
 }

Cheers.