{
"request":"senddata",
"datatype" : "event",
"id" : "123123",
"eventKey":"High Temperature",
"timestamp":"2017-01-13T20:15:57Z",
"eventParameters":{
"Temperature": 25,
"High Temperature": 35,
"Setpoint": 25,
}
}

For the above JSON, I've tried to use a QJsonDocument object like this:

Qt Code:
  1. QByteArray arr = "{\"request\" : \"senddata\","
  2. "\"datatype\" : \"event\","
  3. "\id\" : \"123123\","
  4. "\"eventKey\" : \"High Temperature\","
  5. "\timestamp\" : \"";
  6. arr + dt;
  7. arr += "\","
  8. "\eventParameters\" : {"
  9. "\"Temperature\" : 25,"
  10. "\"High Temperature\" : 30,"
  11. "\"Setpoint\" : 25}}";
  12. doc = QJsonDocument::fromJson(arr);
To copy to clipboard, switch view to plain text mode 

I need this because the timestamp key is a variable. I can't get this to work properly. I've also tried using the insert method with QJsonObjec more like:

Qt Code:
  1. json.insert("id","070707");
  2. json.insert("request","senddata");
  3. json.insert("datatype","event");
  4. json.insert("eventKey","High Temperature");
  5. json.insert("timestamp", QDateTime::currentDateTime().toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate));
  6. ...
To copy to clipboard, switch view to plain text mode 

No joy here either. So my real question is how to prepare the nested JSON example for a REST type POST command. It would also be great to see a JSON array example.

Thanks,
-Rich