MCPcopy Create free account
hub / github.com/dannagle/PacketSender / ExportJSON

Method ExportJSON

src/packet.cpp:182–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180#define JSONNUM(VAR) json[QString(# VAR).toLower()] = QString::number(packetList[i].VAR)
181
182QByteArray Packet::ExportJSON(QList<Packet> packetList)
183{
184 QByteArray returnData;
185
186 QJsonArray jsonArray;
187
188 for (int i = 0; i < packetList.size(); i++) {
189
190
191 QJsonObject json;
192 if (packetList[i].name.isEmpty()) {
193 continue;
194 }
195 json["name"] = packetList[i].name;
196 JSONSTR(hexString);
197 JSONSTR(fromIP);
198 JSONSTR(toIP);
199 JSONSTR(errorString);
200 JSONNUM(port);
201 JSONNUM(fromPort);
202 JSONSTR(tcpOrUdp);
203 JSONNUM(sendResponse);
204 JSONSTR(requestPath);
205 JSONSTR(repeat);
206 json["asciistring"] = QString(packetList[i].asciiString().toLatin1().toBase64());
207 //JSONSTR(timestamp);
208
209 jsonArray.push_front(json);
210 }
211
212 QJsonDocument doc(jsonArray);
213
214 returnData = doc.toJson();
215
216
217 return returnData;
218}
219
220QList<Packet> Packet::ImportJSON(QByteArray data)
221{

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
asciiStringMethod · 0.80

Tested by

no test coverage detected