alternative way to cast unsigned long as string

i want to avoid using the String object for sending a unsinged long as a string of chars. My string is a json object format. Currently i make the string like this,

void handleco2m1ppm() {
  server.send(200, "text/plane", "{\"pwmc02ppm\":[" +
              String(_co2m1Struct.pwmc02ppm) + "]" + "," + "\"uartc02ppm\":[" +
              String(_co2m1Struct.uartc02ppm) + "]" + "," + "\"secondsOn\":[" +
              String(_co2m1Struct.SecondsOn) + "]" +  "}" );

which works but im not sure is this a safe thing to do. end the end i would have to use String hundreds of times through out my code.

I have been having issues with arduinoJson so i thought id attempt to concat my own json object string.

anyone recommend a better approach?


Or sprintf().

1 - text/plain

2 - Check out this from the forum sticky:

  1. Standard libraries (libc)

The Arduino IDE includes ("links") libc - a standard library of common building-blocks that C programs often need. This includes things such as type conversions and string manipulations.

The documentation is here: avr-libc: Modules

C/C++ programmers should make themselves familiar with what kinds of things are already provided in this standard library. In particular, browse through the functions in stdlib.h and string.h and the types in stdint.h .

3 - Use a JSON library for arduino.