Please note: the question originally had no mention of trying to use
c_str()- so I'm not a retard
Point 1 JSON actually is a string
Point 2 your data_json varibale is a String
Point 3 client.publish doesn't work take String as the payload argument, it takes either const char * or const uint8_t *
So, what you can simply do is use Strings c_str method to pas a const char * as the payload
i.e.
client.publish("/devices/data", data_json.c_str());
Point 4 - if you read the pubsubclient documentation, you'll see that
The maximum message size, including header, is 128 bytes by default. This is configurable via MQTT_MAX_PACKET_SIZE in PubSubClient.h. Longer messages can also be sent with the publish_P() method.
so what you may be experiencing now is a message size too big for pubsubclient to handle - set a larger packet size before including the PubSubClientHeader.h
#define MQTT_MAX_PACKET_SIZE 1024
#include <pubsubclient.h>
If that also doesn't work, try
client.publish_P("/devices/data", data_json.c_str());