Variable changes from Particle.publish to Webhook JSON format

I am working on a webhook with multiple variables in a JSON format. When I create the variable and use Particle.publish, I get this output:

            Particle.publish("Name", name);
            Particle.publish("RSSI", curRSSI);

“Name” = “iBeacon”
“RSSI” = “-67”

However, when I try using the JSON format with the same variables, I get this output:

            String data = String::format("{ \"DeviceName\": \"%u\", \"RSSI\": %u }", name.c_str(), curRSSI.c_str());
            Particle.publish("tracking_event", data);

“tracking_event” = {
“DeviceName”: “537036472”
“RSSI”: 536974024

Why are these variables (name and curRSSI) changing?

Both your variables are strings (%s) not an unsigned integers (%u).

What you are doing is trying to interpret the string pointer as integer value, that’s why you are seeing these numbers.

Okay thanks for the explanation! That did it.