Printing an array to node-red text dashboard node

#include <ArduinoJson.h> //install this library
#include <WiFi.h>
DynamicJsonDocument getAccessPointsAsDynamicJson() {
DynamicJsonDocument doc(2560);
JsonArray array = doc.createNestedArray("networks");
Serial.println("Start scanning");
int n = WiFi.scanNetworks();
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
JsonObject nested = array.createNestedObject();
nested["ssid"] = WiFi.SSID(i);
nested["bssid"] = WiFi.BSSIDstr(i);
nested["rssi"] = WiFi.RSSI(i);
nested["channel"] = WiFi.channel(i)
}
return doc;
}

void setup() ;
DynamicJsonDocument doc = getAccessPointsAsDynamicJson();
const char* first_found_ssid = doc["ap"][0]["ssid"];
const int first_found_rssi = doc["ap"][0]["rssi"];
const char* second_found_ssid = doc["ap"][1]["ssid"];
//etc.
Serial.println(first_found_ssid);
Serial.println(first_found_rssi);
Serial.println(second_found_ssid);
}

void loop() {
}

tried this but it gives me zero result when i try to print it.