I have a fairly simple struct Message
which contains two fields of type Envelope
.
struct Envelope
{
char* Payload; //Byte array of message data
char* Signature; //Byte array for signature of endorser
};
struct Message
{
char* configSeq; //Byte array config sequence
Envelope* configMsg;
Envelope* normalMsg;
};
Everything boils down to a byte array (represented as char* since C has no byte type)
I just want to use cJSON to read in a JSON file and deserialize it into a Message object. I have read the entire documentation on the cJSON github page but it doesn't say how to do this. Here is an example of what I want to do:
char* message = checkForMessage();
if (message) //If a message exists
{
//Must parse as JSON
cJSON* json = cJSON_Parse(message);
Message* msg = //have json convert to Message type
checkMessage<<<1, 1>>>(msg, time(0));
}
I've tried using the cJSON functions with object in their name but all those do is modify/return a cJSON*. I need to get it from a cJSON into a different struct.
Thanks for any help.