How split long String data from IR receiver?

Hi, I have nodemcu V3 and IR receiver.
I use the sketch IRrecvDumpV2 from IRremoteESP8266 to decode the data from the AC remote control, I receive this string from my remote control:

Power: On, Mode: 1 (Cool), Temp: 26C, Fan: 1 (Low), Turbo: Off, Quiet: Off, XFan: Off, Ion: On, Light: On, Swing(H): Off, Swing(V): On

I want to split the string to store the name and the state separatly to send the data to the mqtt and the HA.

How can I split this data ?

The strtok() function.

I would start with a C-string, not a String object, and use strtok() to separate out the segments delimited by commas.

Those segments could be further divided into keyword and parameter using strtok() with the blank delimiter.

Thanks, I will try this.

If I want transform this string to a json format?
I try the example from bblanchon json library , string to json, but I didn't succes, did you have an exemple ?

Hi,
I try the strtok() command, I think I success use it.
I want convert it to a json format but I didn't find how do that.

The code from the IRrecvDumpV2 where is the string

String description = IRAcUtils::resultAcToString(&results);
if (description.length()) Serial.println(D_STR_MESGDESC ": " + description);

The String I receive:

Power: Off, Mode: 1 (Cool), Temp: 26C, Fan: 1 (Low), Turbo: Off, Quiet: Off, XFan: Off, Ion: Off, Light: On, Swing(H): Off, Swing(V): On

I use strtok() for converting my code:

char str_array[description.length()+1];
description.toCharArray(str_array, description.length()+1);
char * token = strtok(str_array, " ");
 while (token != NULL) {
    printf ("%s\n",token);
    token = strtok (NULL, " ");
  }

The output is:

Power:
Off,
Mode:
1
(Cool),
Temp:
26C,
Fan:
1
(Low),
Turbo:
Off,
Quiet:
Off,
XFan:
Off,
Ion:
Off,
Light:
On,
Swing(H):
Off,
Swing(V):
On

When I print the first char Serial.println(str_array[0]); I receive the "P" from the Power.
I want transform it to a json format like:

{
"Power": "Off",
"Mode": "1",
"Temp": "25",
"Fan": "1",
"Turbo": "Off",
"Quiet": "Off",
"XFan": "Off",
"Ion": "Off",
"Light": "On",
"Swing(H)": "Off",
"Swing(V)": "On"
}

Try using a comma (",") as the delimiter.
Like so:

char * token = strtok(str_array, ",");
 while (token != NULL) {
    printf ("%s\n",token);
    token = strtok (NULL, ",");
  }

Try using a comma (",") as the delimiter.

Do you need to remove the (Cool) and (Low) bits?

Thanks.
The result the is without a space all others have a space before the name:
It's prefer without (Cool) and (Low) I need only the state.

Power: Off
Mode: 1 (Cool)
Temp: 26C
Fan: 1 (Low)
Turbo: Off
Quiet: Off
XFan: Off
Ion: Off
Light: On
Swing(H): Off
Swing(V): On

I search, google, for converting to a json format, but I didn't find how do that.
The example from json library have a json string on the beginning.
How can I convert this to Json format?