Write and read Json file over esp8266

Greeting,
Wish all be fine and Merry Christmas and also Happy 2022 for all,
I have coded a ESP8266 to operate as STA and AP mode,
everything compiles and runs perfect but I have a problem in saving WiFi credentials hence every time the Module resets I need to insert SSid and Pass,
I found related libraries that can convert WiFi-AP credentials to a Json object with xx.json file format using "ArduinoJson.h> and store it in Flash memory using <FS.h>. but unfortunately I couldn't handle this part. Could any one help me with this Issue?
Here is the code:

//--------------------Libraries----------------------------//
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
//#include <SPIFFS.h>
#include <FS.h>
#include <ArduinoJson.h>
//--------------------------Variables----------------------//
boolean Hide;
int LED = 2;
String ssid;
String password;
ESP8266WebServer server(80);

//-------------------Functiones---------------------------//
void LeD()
{

  if (WiFi.status() != WL_CONNECTED) {
    digitalWrite(LED, LOW);
    delay(10);
  } else
  { digitalWrite(LED, HIGH);
  }
}
//-------------*********--------------------------//
void wifi_connecting()
{
  WiFi.begin(ssid, password);
  Serial.println("");
  int i = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    i = i + 1;
    if (i > 30) {
      Serial.println("wifi not found");
      break;
    }
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

}

//--------------------------Server communication---------------------//
void handleRoot() {
  String html = "<!doctype html><html><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>SSID</title><style>input[type=submit] {width: 100%;padding: 9px;}lable {width: 15% !important;display: block;float: left;}input,select {width: 70%;margin: 5px 0;padding: 10px;border-radius: 5px;border: navajowhite;}body {background: yellow;}form {max-width: 500px;margin: auto;}</style></head><body><form method='post'><lable for='name'>SSID</lable><select name='SSID' id='SSID'>";
  int numberOfNetworks = WiFi.scanNetworks();
  for (int i = 0; i < numberOfNetworks; i++) {
    html += "<option value=\"" + WiFi.SSID(i) + "\">" + WiFi.SSID(i) + "</option>";
  }
  html += "</select><br/><lable for='Password'>PSK</lable><input type='password' name='PSK' id='PSK'><br/><input type='Submit'></form></body></html>";
  server.send(200, "text/html", html);
  if (server.arg("SSID") != "") {
    ssid = server.arg("SSID");
    password = server.arg("PSK");
    wifi_connecting();
  }
}
//-----------------------------Storing Credentials--------------------------//

//-----------------------------Setup Runtime-------------------------------//

void setup(void) {
  Serial.begin(115200);
  pinMode(LED , OUTPUT);
  WiFi.mode(WIFI_STA);
  wifi_connecting();
  WiFi.mode(WIFI_AP);
  WiFi.softAP("XXXXXXXX", "YYYYYYYYYYY", 1 , Hide, 8);
  Serial.print("Wifi Ap IP = ");
  Serial.println(WiFi.softAPIP());
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
  Serial.print("Connected devices = ");
  Serial.println(WiFi.softAPgetStationNum());
}
//--------------------------------Loop Operation-----------------------------//
void loop()
{
  delay(500);
  LeD();
  {
    if ( WiFi.status() == WL_CONNECTED) {
      WiFi.softAPdisconnect(true);
      Hide = true;
    }
    if (WiFi.status() != WL_CONNECTED) {
      Hide = false;
      WiFi.mode(WIFI_AP);
      WiFi.softAP("XXXXXXXX", "YYYYYYYYYYY", 1 , Hide, 8);
    }
  }
  server.handleClient();
}

Your post was MOVED to its current location as it is more suitable

Where do you mean actually?

If you are asking where it was moved to, then it is now in the Programming section of the forum as it is a question about programming

Thanks Bob....

I see no attempt to use ArduinoJson or work with a file in your sketch.

you know that esp8266 stores the ssid and password by it self? https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/generic-class.html#persistent

https://stackoverflow.com/questions/70509739/write-and-read-json-file-over-esp8266

https://arduino.stackexchange.com/questions/88186/write-and-read-json-file-over-esp8266

that is the matter, I can't do it, I made some changes so will Upload the code here to check please....

//--------------------Libraries----------------------------//
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
//#include <SPIFFS.h>
#include <FS.h>
#include <ArduinoJson.h>
//--------------------------Variables----------------------//
boolean Hide;
int LED = 2;
String ssid , password;
String Data;
const char *SSiD , *Pass ;
ESP8266WebServer server(80);

//-------------------Functiones---------------------------//
void LeD()
{
  if (WiFi.status() != WL_CONNECTED) {
    digitalWrite(LED, LOW);
    delay(10);
  } else
  { digitalWrite(LED, HIGH);
  }
}
//-------------*********--------------------------//
void wifi_connecting()
{
  WiFi.mode(WIFI_STA);
  WiFi.begin(SSiD, Pass);
  Serial.println("");
  { int i = 0;
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
      i = i + 1;
      if (i > 30) {
        Serial.println("wifi not found");
        break;
      }
    }
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

//--------------------------Server communication---------------------//
void handleRoot() {
  String html = "<!doctype html><html><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>MAD SHAKR HORIZON</title><style>input[type=submit] {width: 100%;padding: 9px;}lable {width: 15% !important;display: block;float: left;}input,select {width: 70%;margin: 5px 0;padding: 10px;border-radius: 5px;border: navajowhite;}body {background: yellow;}form {max-width: 500px;margin: auto;}</style></head><body><form method='post'><lable for='name'>SSID</lable><select name='SSID' id='SSID'>";
  int numberOfNetworks = WiFi.scanNetworks();
  for (int i = 0; i < numberOfNetworks; i++) {
    html += "<option value=\"" + WiFi.SSID(i) + "\">" + WiFi.SSID(i) + "</option>";
  }
  html += "</select><br/><lable for='Password'>PSK</lable><input type='password' name='PSK' id='PSK'><br/><input type='Submit'></form></body></html>";
  server.send(200, "text/html", html);
  if (server.arg("SSID") != "") {
    ssid = server.arg("SSID");
    password = server.arg("PSK");
    Storing_Credentials();
    wifi_connecting();
  }
}
//-----------------------------Storing Credentials--------------------------//
void Storing_Credentials()
{
  Data = ssid , password ;
  DynamicJsonBuffer jBuffer;
  JsonObject& jObject = jBuffer.parseObject(Data);
  File configFile = SPIFFS.open("/config.json", "w");
  jObject.printTo(configFile);
  configFile.close();
}
//-----------------------------Reading Credentials--------------------------//
void Reading_Credentials()
{
  if (SPIFFS.exists("/config.json"))
  {
    const char *SSiD , *Pass ;
    File configFile = SPIFFS.open("/config.json", "r");
    if (configFile)
    {
      size_t size = configFile.size();
      std::unique_ptr<char[]> buf(new char[size]);
      configFile.readBytes(buf.get(), size);
      configFile.close();

      DynamicJsonBuffer jsonBuffer;
      JsonObject& jObject = jsonBuffer.parseObject(buf.get());
      if (jObject.success())
      {
        SSiD = jObject["ssid"];
        Pass = jObject["password"];
      }
    }
  }
}
//-----------------------------Setup Runtime-------------------------------//

void setup(void) {
  Serial.begin(115200);
  pinMode(LED , OUTPUT);
  SPIFFS.begin();
  Reading_Credentials();
  wifi_connecting();
  server.on("/", handleRoot);
  server.begin();
  Serial.print("Wifi Ap IP = ");
  Serial.println(WiFi.softAPIP());
  Serial.println("HTTP server started");
  Serial.print("Connected devices = ");
  Serial.println(WiFi.softAPgetStationNum());

}
//--------------------------------Loop Operation-----------------------------//
void loop()
{
  delay(1000);
  LeD();
  {
    if ( WiFi.status() == WL_CONNECTED) {
      WiFi.softAPdisconnect(true);
      Hide = true;
    }
    if (WiFi.status() != WL_CONNECTED) {
      Hide = false;
      WiFi.mode(WIFI_AP);
      WiFi.softAP("XXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXX", 1 , Hide, 8);

    }
  }
  server.handleClient();
}