how to construct JSON from array

Hi .. i am trying to control some switches through my webserver and Nodemcu. i am managing to connect to my Database and read data.
I want to send data back to the server but i am not how to construct a JSON from an array.

This is my code :

 if(currentMillis - previousMillis >= interval) {
    if ((WiFiMulti.run() == WL_CONNECTED)) {
      outputsState = httpGETRequest(serverName);
      Serial.println("OutputState ( {ID Key:[Switch ID, State, Mode, AlarmON, AlarmOFF,JustChanged]}");
      Serial.println(outputsState);
      Serial.println(" ");
      
      JSONVar myObject = JSON.parse(outputsState);
        
      if (JSON.typeof(myObject) == "undefined") {
        Serial.println("Parsing input failed!");
        return;
      }
       
      JSONVar keys = myObject.keys();
    
      for (int i = 0; i < keys.length(); i++) {
        JSONVar value = myObject[keys[i]];
        
        Switch_ID[i]              = atoi(value[0]);
        Switch_Mode[i]            = atoi(value[1]);
        Switch_State[i]           = atoi(value[2]);
        Switch_AlarmOn[i]         = atoi(value[3]);
        Switch_AlarmOFF[i]        = atoi(value[4]);
        Switch_JustChanged[i]     = atoi(value[5]);

        if (Switch_Mode[i] == 0 && Switch_State[i] == 0 && Switch_JustChanged[i] == 0) {
              mySwitch315.send(Switch_ID[i], 24); 
              New_State[i] = 1;
              New_JustChanged[i] = 1;
        }
        if (Switch_Mode[i] == 0 && Switch_State[i] == 1 && Switch_JustChanged[i] == 1) {
              mySwitch315.send(Switch_ID[i], 24); 
              New_State[i] = 0;
              New_JustChanged[i] = 0;
        }
        if (Switch_Mode[i] == 1 && Switch_AlarmOn[i] == 1 && Switch_State[i] == 0 && Switch_JustChanged[i] == 0) {
              mySwitch315.send(Switch_ID[i], 24); 
              New_State[i] = 1;
              New_JustChanged[i] = 1;
        }
        if (Switch_Mode[i] == 1 && Switch_AlarmOFF[i] == 1 && Switch_State[i] == 1 && Switch_JustChanged[i] == 1) {
              mySwitch315.send(Switch_ID[i], 24); 
              New_State[i] = 0;
              New_JustChanged[i] = 0;
        }
      }
      Serial.println(Switch_ID[0]);
      Serial.println(Switch_Mode[0]);
      Serial.println(Switch_State[0]);
      Serial.println(Switch_AlarmOn[0]);
      Serial.println(Switch_AlarmOFF[0]);
      Serial.println(Switch_JustChanged[0]);
      Serial.println(New_JustChanged[0]);
      Serial.println(New_State[0]);
             
    previousMillis = currentMillis;

    //How to send back ? ....
    //Post_Response_Data(Switch_ID[], Switch_AlarmON[], Switch_AlarmOFF[], New_JustChanged[], New_State[]);

this my my "outputState" in the monitor :

OutputState ( {ID Key:[Switch ID, State, Mode, AlarmON, AlarmOFF,JustChanged]}

{"3038947":["3038947","0","0","0","0","0"],"3038948":["3038948","0","0","0","0","0"]}

How can i construct a JSON from the arrays : Switch_ID[], ... so i can send it back to the server.
Thanks.

i use this to to json an int array rxhex[] of length rxc
[be warned its a memory pig]

DynamicJsonDocument root(4000);
      present_timestamp = time(nullptr);     // get UNIX timestamp

JsonArray rxh = root.createNestedArray("rx");
      //        uint8_t k = strlen(rxhex);
      for (char i = 0; i < rxc; i++) {
        rxh.add(rxhex[i]);
      }
      root["time"] = present_timestamp;


        String json;
        serializeJson(root, json);
        server.send(200, "application/json", json);
      }

for a large array this way is more efficient memory wise

void ghData() {
  int inx = dayhead - 240, tmp;
  char buff[10];
  String gd = "{\"volts\":[";
  if (inx < 0)inx += 240;
  tmp = inx;
  for (int j = 0; j < 240; j++) {
    dtostrf(dayvolts[tmp++], 3, 1, buff);
    gd += buff;
    if (j != 239)
      gd += ",";
    if (tmp > 239)
      tmp = 0;
  }
  gd += "],\"watts\":[";
  tmp = inx;
  for (int j = 0; j < 240; j++) {
    dtostrf(daywatts[tmp++], 3, 1, buff);
    gd += buff;
    if (j != 239)
      gd += ",";
    if (tmp > 239)
      tmp = 0;
  }
  gd += "]}";
  server.send(200, "application/json", gd);
}