const void FirebaseCloudMessaging::AddToJson( const FirebaseCloudMessage& message, JsonObject& json) const { if (!message.collapse_key.empty()) { json["collapse_key"] = message.collapse_key.c_str(); } json["priority"] = message.high_priority ? "high" : "normal"; json["delay_while_idle"] = message.delay_while_idle; if (message.time_to_live > 0 && message.time_to_live < 2419200) { json["time_to_live"] = message.time_to_live; } if (!message.data.empty()) { JsonObject& data = json.createNestedObject("data"); for (const auto& datum : message.data) { data[datum.first.c_str()] = datum.second.c_str(); } } if (!message.notification.title.empty() || !message.notification.body.empty()) { JsonObject& notification = json.createNestedObject("notification"); if (!message.notification.title.empty()) { notification["title"] = message.notification.title.c_str(); } if (!message.notification.body.empty()) { notification["body"] = message.notification.body.c_str(); } } }