One should be able to do this:
JSON::Object obj{Poco::JSON_PRESERVE_KEY_ORDER};
obj
.set("protocol"s, "v2"s)
.set("device"s, device)
.set("at"s, "now"s)
.set("data"s, JSON::Object()
.set("temperature"s, temperature));
Same for Array::add() and Array::set().