String within payload always comes as null on Arduino side


I have been using Losant with ESP8266 and ESP32 for a while now, always exchanging numbers and bolleans between the dashboard and the microcontroller. But now I need to send a string from the Dashboard to the microcontrollers (some 40 chars).
So, I create a String attribute -> create an input text box on Dashboard with that attribute set on the ‘Attribute’ field -> give a name to thee template id in thatinput box -> Add a button trigger and set its payload as follows:


And that’s it on the Losant side, on the Arduino IDE side, I have the hanles as follows:

void handleCommand(LosantCommand *command) {
  JsonObject& payload = *command->payload;
  serializeJson(payload, Serial);
  if (strcmp(command->name, "Template_id") == 0) {
    msgs[1] = payload["Some_text"].as<String>();

All works fine with numbers, for example, if I send 45 on the input box, I get the print on Arduino IDE:

But if I send letters…all I get is null.

On the Device Log, on Losant, I can see, for example if I send an Hello:

 "payload":"{\r\n \"Some_text\":Hello\r\n}\r\n"

But on Arduino, always a null =
Any ideia?
I have been reading all I can find about Strings ectraction on payloads, theres a few posts but none of the solutions solved my problem =\

Thank you.
Cheers, Luís Pereira.

I’m adding some pictures for clarification:

Hi @Luis_Pereira,

It sounds as though your entire object is being stringified prior to reaching the workflow, likely as the values are not recognized as JSON. I would recommend formatting your block like so to format the string:


Please let me know if this addition does not resolve the issue!


Hi Julia

Your suggestion worked!
With the payload block as you suggested:

If I send on the input box and Hello, causes the Log on Losant:

“payload”:{} 1 key

  • “Some_text”:“Hello”

And I get on Arduino IDE with the previous print mentioned before ( serializeJson(payload, json_string):wink: the following:


No longer null! Now I can start parsing the string for my information :slight_smile:
Thank you so much!
Cheers, Luís Pereira.