Sending IP address via MQTT

To work around a problem I have I have decided I shall send the IP address back to the MQTT broker and deal with it another way.

The bit of code I have is this:

  client.publish(idTopic, ...........);

And that is where I fall over.

I can't put localIP() in there as it is (for instance) and that isn't liked by the client.publish( ) part.

How can I "format" the localIP() so it will be accepted in the line?

Found the answer/ a way of doing it. This is how.

      snprintf(ip_addr, 60, "{\"WIFI-DEVICE\":\"GPS SENSOR\",\"IP Address\":\"%ld.%ld.%ld.%ld\"}" , ip[0], ip[1], ip[2], ip[3]);