Formatting JSON Array to node-red

Hi, I have an ESP8266 program that prints the networks scanned and places them in a JSON Array. I'm trying to send it to via mqtt and node-red. I've also converted it into a String in arduino but when I connect a text node it prints the array with braces and quotations. How do I program node-red into printing only the SSID and RSSI values, and a new line for every network found.

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = "Tenda_FE2038";
const char* password = "huertas032793";
const char* mqtt_server = "";

WiFiClient espClient;
PubSubClient client(espClient);

void callback(String topic, byte* message, unsigned int length) {
 // Serial.print("Message arrived on topic: ");
  Serial.print(". Message: ");
  String messageTemp;
  for (int i = 0; i < length; i++) {
    messageTemp += (char)message[i];


void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP8266Client")) {
      // Subscribe or resubscribe to a topic
      // You can subscribe to more topics (to control more LEDs in this example)
    } else {
      Serial.print("failed, rc=");
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying

DynamicJsonDocument getAccessPointsAsDynamicJson() { 
  DynamicJsonDocument doc(2560); 
  JsonArray array = doc.createNestedArray("Networks: "); 
  Serial.println("Start scanning"); 
  int n = WiFi.scanNetworks();
  Serial.println(" networks found"); 
  for (int i = 0; i < n; ++i)
  { JsonObject 
  nested = array.createNestedObject(); 
  nested["ssid"] = WiFi.SSID(i); 
 // nested["bssid"] = WiFi.BSSID(i); 
  nested["rssi"] = WiFi.RSSI(i);
 // nested["channel"] =; 
  return doc; 

void setSerial() 

while (!Serial) continue;

void setup() 
  Serial.print("Connecting to ");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  // Print local IP address and start web server
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");

  client.setServer(mqtt_server, 1883);


void loop()

    if (!client.connected()) {
 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"]; 

String myOutput; serializeJson(doc, myOutput);
char myOutput_char[200];
myOutput.toCharArray(myOutput_char, 200);

[{"id":"889428da.48e2f8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"6b64ab7b.cd1ac4","type":"json","z":"889428da.48e2f8","name":"","property":"payload","action":"obj","pretty":true,"x":530,"y":300,"wires":[["301f0300.9c21fe"]]},{"id":"249daef3.964e22","type":"mqtt in","z":"889428da.48e2f8","name":"","topic":"name/test","qos":"0","datatype":"auto","broker":"6669e693.9f8508","x":360,"y":360,"wires":[["aaf0037d.3a5a7","6b64ab7b.cd1ac4"]]},{"id":"301f0300.9c21fe","type":"ui_text","z":"889428da.48e2f8","group":"13637635.f64a3a","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"col-center","x":690,"y":260,"wires":[]},{"id":"aaf0037d.3a5a7","type":"debug","z":"889428da.48e2f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":420,"wires":[]},{"id":"6669e693.9f8508","type":"mqtt-broker","z":"","name":"mosquitto","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"13637635.f64a3a","type":"ui_group","z":"","name":"rssi","tab":"a9b73d04.c94c9","disp":true,"width":"6","collapse":false},{"id":"a9b73d04.c94c9","type":"ui_tab","z":"","name":"Home","icon":"mic","disabled":false,"hidden":false}]

this is the flow im working on


this is what the output looks like in text node

Try selecting Parsed Json Object in the Output field of the MQTT node. Feed that into a debug node and make sure that it now shows as a javascript object. Then read the node red docs page on Working With Messages which will help you find how to extract the data you want.

Looks like there is already a json node in the flow -- but the ui_text node is converting the entire msg.payload back to a string for display... For the text format, try referencing just the field you want to display (SSID, RSSI, etc).

One caveat -- you are using the string "Networks: " as the property name, which will be hard to work with in Javascript. I would change that to just the plain word Networks without any punctuation or spaces. That way your ui_text format could be {{msg.payload.Networks[0].ssid}} for example.

I do not think that the simple text node will display an array of strings -- for that you might need a bit of Angular syntax embedded in a ui_template node, or maybe look at one of the html table nodes.

As I wrote before, take a look at the ui-list or ui-table dashboard nodes (installable via the palette menu) You still have to do some conversions but this could be done with a function node or other node red standard nodes

Thank you all for you suggestions. I have succesfully edited it via template node with this code

    <li ng-repeat="x in msg.payload.Networks">
        <span>{{x.ssid}}: {{x.rssi}}</span>

im passing the json string through a json node as a javascript object.

However i've run into a weird problem. My ESP8266 now doesn't send data through mqtt. It worked for about 10mins then stopped sending the data. I've tried connecting the device to a different router, and even uploading the code to a new one. But the problem persist. Is this a problem with node-red?