How use JSON template in string ?

Oct 16, 2020 at 8:17pm
I want to send

{state:success,value:i} // i is a float, take values from some function

like the JSON template format over TCP server socket, if I don't use the JSON library can I create and send JSON template in string or char array?

Last edited on Oct 16, 2020 at 8:17pm
Oct 16, 2020 at 10:10pm
Sure.
1
2
3
std::stringstream stream;
stream << "{\"state\":" << success << ",\"value\":" << value << "}";
std::string json = stream.str();
Oct 17, 2020 at 1:18pm
@helios thank you for replying to my question
Topic archived. No new replies allowed.