void History::fromJson(JsonArray& json) { int i,j; for (i = json.size() > N ? json.size() - N : 0, j = 0; i < json.size(); i++, j++) { _records[j] = json.get(i); } _last = j; }
Status loginServerUploadLogs(const Account *account) { const auto url = ABC_SERVER_ROOT "/account/debug"; JsonPtr json; HttpReply reply; DataChunk logData = debugLogLoad(); if (account) { JsonArray jsonArray; auto ids = account->wallets.list(); for (const auto &id: ids) { std::shared_ptr<Wallet> wallet; if (cacheWallet(wallet, nullptr, id.c_str())) { DataChunk watchData; ABC_CHECK(fileLoad(watchData, watcherPath(*wallet))); jsonArray.append( json_string(base64Encode(watchData).c_str())); } } json.reset(json_pack("{ss, ss, ss}", ABC_SERVER_JSON_L1_FIELD, base64Encode(account->login.lobby.authId()).c_str(), ABC_SERVER_JSON_LP1_FIELD, base64Encode(account->login.authKey()).c_str(), "log", base64Encode(logData).c_str())); if (jsonArray) json_object_set(json.get(), "watchers", jsonArray.get()); } else { json.reset(json_pack("{ss}", "log", base64Encode(logData).c_str())); } ABC_CHECK(AirbitzRequest().post(reply, url, json.encode())); return Status(); }
void JsonObject::putArray(const QString& key, const JsonArray& value) { o.insert(key, value.get()); }