Parsing byte(string) to uint array (JSON,IRsend)

Dear Everyone,
Im new to the platform and programming too, i would like to get IR Commands via JSON and send it with IRSEND. Here is my code:

server.onRequestBody((AsyncWebServerRequest * request, uint8_t data, size_t len, size_t index, size_t total) {
Serial.println("Running");
if (request->url() == "/test") {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject((const char
)data);
if (root.success()) {
if (root.containsKey("command")) {
Serial.println(root["command"].asString()); // Hello
uint8_t cmd = root["command"];

irsend.sendGree(cmd);

}
}
request->send(200, "text/plain", "end");
}
});

I sending the code like this:

curl -i -X POST -H 'Content-Type: application/json' -d '{"command": "0x19, 0x00, 0x60, 0x50x00, 0x00, 0x00, 0x30"}' http://192.168.0.185/test

Or

curl -i -X POST -H 'Content-Type: application/json' -d '{"command": "[0x19, 0x00, 0x60, 0x50x00, 0x00, 0x00, 0x30]"}' http://192.168.0.185/test

It is arriving, but not seem to working.

I have a working code, but the ir commands are hardcoded. Example:

//Declaration
uint8_t Power_ON[8] = {0x19, 0x09, 0x60, 0x50, 0x00, 0x00, 0x00, 0xC0};

//Called like
irsend.sendGree(Power_ON);

So the command is comming as char, but it is a byte actually. Please help. Thank you!

rip :frowning:

In your hardcoded example, your command is an array of uint8_t. In your json example, ‘cmd’ is a single uint_8, not an array.

Hello, thank you for your answer.
May i ask, how to get the data in array?

blh64:
In your hardcoded example, your command is an array of uint8_t. In your json example, 'cmd' is a single uint_8, not an array.

It really depends on what

uint8_t cmd = root["command"];

this command returns. I don’t know. You can read the docs on your json library. Maybe it returns a string of all the values that you have to parse with strtok() or similar. Maybe it returns an pointer to the array but you are just assigning it to an uint8_t rather than a pointer to an array.