user46904: #include <ArduinoJson.h>      
#include <FS.h>    

/* Set these to desired credentials in runtime */
struct Config {
  String ssid = "";
  String pass = "";
  bool hFlag = false;
};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("");
  delay(1000);

  //allows serving of files from SPIFFS
  Serial.println("Mounting FS...");
  if (!SPIFFS.begin()) {
    Serial.println("Failed to mount file system");
    return;
  }

  if (readConfigFile("/LaSt.json", false)) {
    Serial.println("Config read");
  } else {
    Serial.println("Failed to read config");
  }
}

bool readConfigFile(char* fileName, bool whichFile)
{
  File configFile = SPIFFS.open(fileName, "r");
  if (!configFile) {
    Serial.println("Failed to open config file");
    return false;
  }

  size_t size = configFile.size();
  if (size > 1024) {
    Serial.println("Config file size is too large");
    return false;
  }

  // Allocate the memory pool on the stack.
  // Use arduinojson.org/assistant to compute the capacity.
  StaticJsonBuffer<256> jsonBuffer;

  // Parse the root object
  JsonObject &root = jsonBuffer.parseObject(configFile);

  if (!root.success())
    Serial.println(F("Failed to read file, using default configuration"));

  // Copy values from the JsonObject to the Config
  Config.ssid = root["ssid"];
  Config.pass = root["pass"];
  if (whichFile)
  {
    Config.hFlag = root["hFlag"];
  }

  // We don't need the file anymore
  configFile.close();

  return true;
}

Compile gives error in Copy values from the JsonObject to the Config section. Error: expected unqualified-id before '.' token.
Want to read file from SPIFFS, and store in variable to use.

user27653: Your code at the top:
struct Config {
  String ssid = "";
  String pass = "";
  bool hFlag = false;
};

defines a variable "type". It's like making a new int or bool, but yours is called struct Config. 
After making the type, you need to create declare an instance of it.
struct Config cfg;

Then, you refer to the one you created:
  // Copy values from the JsonObject to the Config struct named cfg
  cfg.ssid = root["ssid"];
  cfg.pass = root["pass"];
  if (whichFile)
  {
    cfg.hFlag = root["hFlag"];
  }

Note that a particular issue with ArduinoJSON and Strings is that you may get an error like:
error: ambiguous overload for 'operator=' (operand types are 'String' and 'ArduinoJson::JsonObjectSubscript<const char*>')

There is an ArduinoJSON FAQ entry that states

Most of the time you can rely on implicit casts.
But there is one notable exception: when you convert a JsonVariant to
  a String.
For example:
String ssid = network["ssid"];
ssid = network["ssid"];

The first line will compile but the second will fail with the
  following error:
error: ambiguous overload for 'operator=' (operand types are 'String' and 'ArduinoJson::JsonObjectSubscript<const char*>')

The solution is to remove the ambiguity with any of the following replacement:
ssid = (const char*)network["ssid"];
ssid = network["ssid"].as<const char*>();
ssid = network["ssid"].as<String>();



46904: <pre><code>#include &lt;ArduinoJson.h&gt;      
#include &lt;FS.h&gt;    

/* Set these to desired credentials in runtime */
struct Config {
  String ssid = "";
  String pass = "";
  bool hFlag = false;
};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("");
  delay(1000);

  //allows serving of files from SPIFFS
  Serial.println("Mounting FS...");
  if (!SPIFFS.begin()) {
    Serial.println("Failed to mount file system");
    return;
  }

  if (readConfigFile("/LaSt.json", false)) {
    Serial.println("Config read");
  } else {
    Serial.println("Failed to read config");
  }
}

bool readConfigFile(char* fileName, bool whichFile)
{
  File configFile = SPIFFS.open(fileName, "r");
  if (!configFile) {
    Serial.println("Failed to open config file");
    return false;
  }

  size_t size = configFile.size();
  if (size &gt; 1024) {
    Serial.println("Config file size is too large");
    return false;
  }

  // Allocate the memory pool on the stack.
  // Use arduinojson.org/assistant to compute the capacity.
  StaticJsonBuffer&lt;256&gt; jsonBuffer;

  // Parse the root object
  JsonObject &amp;root = jsonBuffer.parseObject(configFile);

  if (!root.success())
    Serial.println(F("Failed to read file, using default configuration"));

  // Copy values from the JsonObject to the Config
  Config.ssid = root["ssid"];
  Config.pass = root["pass"];
  if (whichFile)
  {
    Config.hFlag = root["hFlag"];
  }

  // We don't need the file anymore
  configFile.close();

  return true;
}
</code></pre>

<p>Compile gives error in <code>Copy values from the JsonObject to the Config</code> section. Error: <code>expected unqualified-id before '.' token</code>.</p>

<p>Want to read file from SPIFFS, and store in variable to use.</p>
 27653: <p>Your code at the top:</p>

<pre><code>struct Config {
  String ssid = "";
  String pass = "";
  bool hFlag = false;
};
</code></pre>

<p>defines a variable "type". It's like making a new <code>int</code> or <code>bool</code>, but yours is called <code>struct Config</code>. </p>

<p>After making the type, you need to create declare an instance of it.</p>

<pre><code>struct Config cfg;
</code></pre>

<p>Then, you refer to the one <strong>you</strong> created:</p>

<pre><code>  // Copy values from the JsonObject to the Config struct named cfg
  cfg.ssid = root["ssid"];
  cfg.pass = root["pass"];
  if (whichFile)
  {
    cfg.hFlag = root["hFlag"];
  }
</code></pre>

<p>Note that a particular issue with ArduinoJSON and Strings is that you may get an error like:</p>

<pre><code>error: ambiguous overload for 'operator=' (operand types are 'String' and 'ArduinoJson::JsonObjectSubscript&lt;const char*&gt;')
</code></pre>

<p>There is an <a href="https://arduinojson.org/v5/faq/how-to-fix-error-ambiguous-overload-for-operator/" rel="nofollow noreferrer">ArduinoJSON FAQ entry</a> that states</p>

<blockquote>
  <p>Most of the time you can rely on implicit casts.</p>
  
  <p>But there is one notable exception: when you convert a JsonVariant to
  a String.</p>
  
  <p>For example:</p>

<pre><code>String ssid = network["ssid"];
ssid = network["ssid"];
</code></pre>
  
  <p>The first line will compile but the second will fail with the
  following error:</p>

<pre><code>error: ambiguous overload for 'operator=' (operand types are 'String' and 'ArduinoJson::JsonObjectSubscript&lt;const char*&gt;')
</code></pre>
  
  <p>The solution is to remove the ambiguity with any of the following replacement:</p>

<pre><code>ssid = (const char*)network["ssid"];
ssid = network["ssid"].as&lt;const char*&gt;();
ssid = network["ssid"].as&lt;String&gt;();
</code></pre>
</blockquote>
