json::Object connectionJson(const Connection& connection) { // form the action array json::Array actions; for (const ConnectionAction& action : connection.actions) { actions.push_back(connectionActionJson(action)); } // form the object type array json::Array objectTypes; for (const ConnectionObjectType& type : connection.objectTypes) { objectTypes.push_back(connectionObjectTypeJson(type)); } json::Object connectionJson; connectionJson["id"] = connectionIdJson(connection.id); connectionJson["connect_code"] = connection.connectCode; connectionJson["display_name"] = connection.displayName; connectionJson["last_used"] = connection.lastUsed; connectionJson["actions"] = actions; connectionJson["object_types"] = objectTypes; connectionJson["icon_path"] = connection.icon; connectionJson["icon_data"] = iconData("drivers", connection.id.type, connection.icon); return connectionJson; }
json::Array ActiveConnections::activeConnectionsAsJson() { json::Array connectionsJson; for (std::set<ConnectionId>::const_iterator it = activeConnections_.begin(); it != activeConnections_.end(); ++it) { connectionsJson.push_back(connectionIdJson(*it)); } return connectionsJson; }