-1

Is it possible to encode a C char array (char*) in JSON in order to send it through a TCP socket? If so how can I make it and which would be a simple JSON library to use?

Thanks,

Nesrine Hadj Khelil
  • 278
  • 1
  • 4
  • 13

1 Answers1

1

You probably don't need to use JSON. If you just want to send a simple message (e.g. "Hi, how are ya"), then you can just send the char array. You cannot send JSON, only a char array of JSON (JSON is a data format, not a transfer protocol).
Example

const char *json = "{\"id\": 12837, \"name\": \"Massimo Isonni\"}"
// You would then send json.

If you need to serialize a struct into a JSON string, I would recommend this.

Isacc Barker
  • 507
  • 4
  • 15