Пример #1
0
CString GetJsonString()
{
  // TEST ROUNDTRIP SOAP -> JSON
  CString namesp("http://test.marlin.org/interface");
  CString action("FirstAction");
  SOAPMessage msg(namesp,action);
  msg.SetParameter("First", 101);
  msg.SetParameter("Second",102);
  XMLElement* elem = msg.AddElement(NULL,"Third",(XmlDataType)XDT_String,"");
  if(elem)
  {
    msg.AddElement(elem,"Fortune",XDT_Integer,"1000000");
    msg.AddElement(elem,"Glory",  XDT_String, "Indiana Jones");
    msg.AddElement(elem,"Diacrit",XDT_String, "יבםףתכהןצ�טאלעשךגמפ�");
  }
  JSONMessage json(&msg);
  json.SetWhitespace(true);
  CString str = json.GetJsonMessage();

  return str;
}
Json::Value PlaceExecutionReport::toJson() const {
    Json::Value json(Json::objectValue);
    if (customerRef != "") {
        json["customerRef"] = customerRef;
    }
    if (status.isValid()) {
        json["status"] = status.getValue();
    }
    if (errorCode.isValid()) {
        json["errorCode"] = errorCode.getValue();
    }
    if (marketId != "") {
        json["marketId"] = marketId;
    }
    if (instructionReports.size() > 0) {
        for (unsigned i = 0; i < instructionReports.size(); ++i) {
            json["instructionReports"].append(instructionReports[i].toJson());
        };
    }
    return json;
}
Пример #3
0
string getJson(connection_info_struct* con_info){
    
    myMeta metadata;
    metadataDSPFactory(con_info->fLLVMFactory, &metadata);
    con_info->fNameApp = metadata.name;
        
    //This instance is used only to build json interface, then it's deleted
    llvm_dsp* dsp = createDSPInstance(con_info->fLLVMFactory);
    
    JSONUI json(dsp->getNumInputs(), dsp->getNumOutputs());
    dsp->buildUserInterface(&json);    
    string answer = json.JSON();
    
    printf("JSON = %s\n", answer.c_str());
        
    deleteDSPInstance(dsp);
    
//    con_info->fNumInstances = 1;
    
    return answer;
}
Пример #4
0
	/**
	 * Reject the Request.
	 * @param reason  Description string.
	 */
	void Request::Reject(const char* reason)
	{
		MS_TRACE();

		static const Json::StaticString k_id("id");
		static const Json::StaticString k_rejected("rejected");
		static const Json::StaticString k_reason("reason");

		MS_ASSERT(!this->replied, "Request already replied");
		this->replied = true;

		Json::Value json(Json::objectValue);

		json[k_id] = (Json::UInt)this->id;
		json[k_rejected] = true;

		if (reason)
			json[k_reason] = reason;

		this->channel->Send(json);
	}
Пример #5
0
		void testComplex()
		{
			QVariantMap map;
			map["string_foo"] = "foo";
			map["bool_true"] = true;
			map["int_42"] = 42;
			map["double_pi"] = 3.14159;
			map["recurse"] = map;
			QVariantList list;
			list.append("zero");
			list.append("one");
			map["list"] = list;

			QStringList list2;
			for(int i = 0; i < 25; i++)
				list2.append(QString("element").append(QString::number(i)));
			map["list2"] = list2;

			QString json(JsonQt::VariantToJson::parse(map));
			QCOMPARE(map, JsonQt::JsonToVariant::parse(json).toMap());
		}
Пример #6
0
Status
loginServerCreate(const Lobby &lobby, DataSlice LP1,
                  const CarePackage &carePackage, const LoginPackage &loginPackage,
                  const std::string &syncKey)
{
    const auto url = ABC_SERVER_ROOT "/account/create";
    JsonPtr json(json_pack("{ssssssssss}",
                           ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(),
                           ABC_SERVER_JSON_LP1_FIELD, base64Encode(LP1).c_str(),
                           ABC_SERVER_JSON_CARE_PACKAGE_FIELD, carePackage.encode().c_str(),
                           ABC_SERVER_JSON_LOGIN_PACKAGE_FIELD, loginPackage.encode().c_str(),
                           ABC_SERVER_JSON_REPO_FIELD, syncKey.c_str()));

    HttpReply reply;
    ABC_CHECK(AirbitzRequest().post(reply, url, json.encode()));
    ServerReplyJson replyJson;
    ABC_CHECK(replyJson.decode(reply.body));
    ABC_CHECK(replyJson.ok());

    return Status();
}
Пример #7
0
void CreateDefaultRepoRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("CreateDefaultRepoRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    QMap<QString, QVariant> dict = mapFromJSON(json.data(), &error);

    if (!dict.contains("repo_id")) {
        emit failed(ApiError::fromJsonError());
        return;
    }

    emit success(dict.value("repo_id").toString());
}
Пример #8
0
json parser::parse_bool(
    const std::string& input, size_t& offset, std::error_code& error)
{
    json boolean;
    if (input.substr(offset, 4) == "true")
    {
        boolean = true;
    }
    else if (input.substr(offset, 5) == "false")
    {
        boolean = false;
    }
    else
    {
        error = std::make_error_code(std::errc::invalid_argument);
        // Error: expected bool ('true' or 'false')
        return json(class_type::null);
    }
    offset += boolean.to_bool() ? 4 : 5;
    return boolean;
}
Пример #9
0
void mod_manager::save_mods_list(WORLDPTR world) const
{
    if (world == NULL || world->active_mod_order.empty()) {
        return;
    }
    const std::string path = get_mods_list_file(world);
    std::ofstream mods_list_file(path.c_str(), std::ios::out | std::ios::binary);
    if(!mods_list_file) {
        popup(_("Can not open %s for writing"), path.c_str());
    }
    try {
        mods_list_file.exceptions(std::ios::failbit | std::ios::badbit);
        JsonOut json(mods_list_file, true); // pretty-print
        json.write(world->active_mod_order);
    } catch(std::ios::failure &) {
        // this might happen and indicates an I/O-error
        popup(_("Failed to write to %s"), path.c_str());
    } catch (std::string e) {
        popup( _( "Failed to write list of mods to %s: %s" ), path.c_str(), e.c_str() );
    }
}
Пример #10
0
// ----------------------------------------------------------------------------
//
bool HttpRestServices::query_music_playlists( Venue* venue, DMXHttpSession* session, CString& response, LPCSTR data )
{
    JsonBuilder json( response );
    json.startObject();

    PlayerItems playlists;
    studio.getMusicPlayer()->getPlaylists( playlists );

    json.startArray( "playlists" );
    for ( PlayerItems::iterator it=playlists.begin(); it != playlists.end(); it++ ) {
        json.startObject();
        json.add( "link", (*it) );
        json.add( "name", studio.getMusicPlayer()->getPlaylistName( (*it) ) );
        json.endObject();
    }
    json.endArray( "playlists" );
        
    json.endObject();

    return true;
}
Пример #11
0
NS_IMETHODIMP
IDBCursor::GetValue(JSContext* aCx,
                    jsval* aValue)
{
  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

  nsresult rv;

  if (mType == INDEX) {
    const Key& value = mKeyData[mDataIndex].value;
    NS_ASSERTION(!value.IsUnset() && !value.IsNull(), "Bad key!");

    rv = IDBObjectStore::GetJSValFromKey(value, aCx, aValue);
    NS_ENSURE_SUCCESS(rv, rv);

    return NS_OK;
  }

  if (!mHaveCachedValue) {
    JSAutoRequest ar(aCx);

    if (!mJSRuntime) {
      JSRuntime* rt = JS_GetRuntime(aCx);
      JSBool ok = js_AddRootRT(rt, &mCachedValue,
                               "IDBCursor::mCachedValue");
      NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);

      mJSRuntime = rt;
    }

    nsCOMPtr<nsIJSON> json(new nsJSON());
    rv = json->DecodeToJSVal(mData[mDataIndex].value, aCx, &mCachedValue);
    NS_ENSURE_SUCCESS(rv, rv);

    mHaveCachedValue = true;
  }

  *aValue = mCachedValue;
  return NS_OK;
}
Пример #12
0
void JSONUtil::getDocument(const string& jsonTxt, JSONElement& root)
{
	string json(jsonTxt);
	root.setType(JSONElement::JSON_OBJECT);
	root.setName("_JSON_ROOT");
	int arrst = json.find("[");
	int objst = json.find("{");
	if(json.find("{")!=string::npos && json.find("}")!=string::npos && (objst<arrst || arrst==(int)string::npos))
	{
		root.setType(JSONElement::JSON_OBJECT);
		StringUtil::replaceFirst(json, "{", "");
		StringUtil::replaceLast(json, "}", "");
		readJSON(json,false,&root);
	}
	else if(json.find("[")!=string::npos && json.find("]")!=string::npos)
	{
		root.setType(JSONElement::JSON_ARRAY);
		StringUtil::replaceFirst(json, "[", "");
		StringUtil::replaceLast(json, "]", "");
		readJSON(json,true,&root);
	}
}
Пример #13
0
void
RankFeaturesDFW::insertField(uint32_t docid, GeneralResult *, GetDocsumsState *state,
                             ResType type, vespalib::slime::Inserter &target)
{
    if (state->_rankFeatures.get() == nullptr) {
        state->_callback.FillRankFeatures(state, _env);
        if (state->_rankFeatures.get() == nullptr) { // still no rank features to write
            return;
        }
    }
    const FeatureSet::StringVector & names = state->_rankFeatures->getNames();
    const feature_t * values = state->_rankFeatures->getFeaturesByDocId(docid);
    if (type == RES_FEATUREDATA && values != nullptr) {
        vespalib::slime::Cursor& obj = target.insertObject();
        for (uint32_t i = 0; i < names.size(); ++i) {
            vespalib::Memory name(names[i].c_str(), names[i].size());
            obj.setDouble(name, values[i]);
        }
        return;
    }
    vespalib::JSONStringer & json(state->_jsonStringer);
    if (values != nullptr) {
        json.clear();
        json.beginObject();
        for (uint32_t i = 0; i < names.size(); ++i) {
            featureDump(json, names[i], values[i]);
        }
        json.endObject();
        vespalib::Memory value(json.toString().data(),
                                      json.toString().size());
        if (type == RES_STRING || type == RES_LONG_STRING) {
            target.insertString(value);
        }
        if (type == RES_DATA || type == RES_LONG_DATA) {
            target.insertData(value);
        }
        json.clear();
    }
}
Пример #14
0
bool guard_action::do_run(void)
{
	acl::json json(data_);
	if (!json.finish()) {
		logger_error("invalid data=|%s|", data_.c_str());
		return false;
	}

	acl::json_node* node = json["cmd"];
	if (node == NULL)
		return on_service_list(json); // just for the old json data;

	const char* cmd = node->get_text();
	if (cmd == NULL)
		return on_service_list(json);

	if (strcasecmp(cmd, "service_dead") == 0)
		return on_service_dead(json);
	else
		return on_service_list(json);

}
Пример #15
0
void LoginRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t* root = parseJSON(reply, &error);
    if (!root) {
        qWarning("failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    const char* token =
        json_string_value(json_object_get(json.data(), "token"));
    if (token == NULL) {
        qWarning("failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    emit success(token);
}
Json::Value AccountFundsResponse::toJson() const {
    Json::Value json(Json::objectValue);
    if (availableToBetBalance >= 0) {
        json["availableToBetBalance"] = availableToBetBalance;
    }
    if (exposure >= 0) {
        json["exposure"] = exposure;
    }
    if (retainedCommission >= 0) {
        json["retainedCommission"] = retainedCommission;
    }
    if (exposureLimit >= 0) {
        json["exposureLimit"] = exposureLimit;
    }
    if (discountRate >= 0) {
        json["discountRate"] = discountRate;
    }
    if (pointsBalance > 0) {
        json["pointsBalance"] = pointsBalance;
    }
    return json;
}
Пример #17
0
void GetUnseenSeahubNotificationsRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetUnseenSeahubNotificationsRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    QMap<QString, QVariant> ret = mapFromJSON(root, &error);

    if (!ret.contains("count")) {
        emit failed(ApiError::fromJsonError());
        return;
    }

    int count = ret.value("count").toInt();
    emit success(count);
}
Пример #18
0
const ConfigValue
FRTConfigResponseV3::readConfigValue() const
{
    vespalib::string md5(_data->get()[RESPONSE_CONFIG_MD5].asString().make_string());
    CompressionInfo info;
    info.deserialize(_data->get()[RESPONSE_COMPRESSION_INFO]);
    Slime * rawData = new Slime();
    SlimePtr payloadData(rawData);
    DecompressedData data(decompress(((*_returnValues)[1]._data._buf), ((*_returnValues)[1]._data._len), info.compressionType, info.uncompressedSize));
    if (data.memRef.size > 0) {
        size_t consumedSize = JsonFormat::decode(data.memRef, *rawData);
        if (consumedSize == 0) {
            std::string json(make_json(*payloadData, true));
            LOG(error, "Error decoding JSON. Consumed size: %lu, uncompressed size: %u, compression type: %s, assumed uncompressed size(%u), compressed size: %u, slime(%s)", consumedSize, data.size, compressionTypeToString(info.compressionType).c_str(), info.uncompressedSize, ((*_returnValues)[1]._data._len), json.c_str());
            LOG_ABORT("Error decoding JSON");
        }
    }
    if (LOG_WOULD_LOG(spam)) {
        LOG(spam, "read config value md5(%s), payload size: %lu", md5.c_str(), data.memRef.size);
    }
    return ConfigValue(PayloadPtr(new V3Payload(payloadData)), md5);
}
Пример #19
0
Json::Value SubscriptionHistory::toJson() const {
    Json::Value json(Json::objectValue);
    if (subscriptionToken != "") {
        json["subscriptionToken"] = subscriptionToken;
    }
    if (expiryDateTime.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &expiryDateTime);
        json["expiryDateTime"] = std::string(buffer);
    }
    if (expiredDateTime.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &expiredDateTime);
        json["expiredDateTime"] = std::string(buffer);
    }
    if (createdDateTime.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &createdDateTime);
        json["createdDateTime"] = std::string(buffer);
    }
    if (activationDateTime.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &activationDateTime);
        json["activationDateTime"] = std::string(buffer);
    }
    if (cancellationDateTime.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &cancellationDateTime);
        json["cancellationDateTime"] = std::string(buffer);
    }
    if (subscriptionStatus.isValid()) {
        json["subscriptionStatus"] = subscriptionStatus.getValue();
    }
    if (clientReference != "") {
        json["clientReference"] = clientReference;
    }
    return json;
}
            WeatherMenuModule::WeatherMenuModule(Eegeo::Helpers::IFileIO& fileIO,
                                                 Eegeo::Resources::CityThemes::ICityThemesService& themesService,
                                                 Eegeo::Resources::CityThemes::ICityThemesUpdater& themesUpdater,
                                                 ExampleAppMessaging::TMessageBus& messageBus,
                                                 Metrics::IMetricsService& metricsService)
            {
                m_pMenuModel = Eegeo_NEW(Menu::View::MenuModel)();
                m_pMenuOptionsModel = Eegeo_NEW(Menu::View::MenuOptionsModel)(*m_pMenuModel);

                std::fstream stream;
                size_t size;

                if(!fileIO.OpenFile(stream, size, "weatherstates.json"))
                {
                    Eegeo_ASSERT(false, "Failed to load weatherstates.json definitions file.");
                }

                std::string json((std::istreambuf_iterator<char>(stream)),
                                 (std::istreambuf_iterator<char>()));

                std::vector<WeatherMenuStateModel> weatherStates;
                if(!WeatherMenuDataParser::ParseWeatherStates(json, weatherStates))
                {
                    Eegeo_ASSERT(false, "Failed to parse weatherstates.json definitions file.");
                }

                m_pWeatherController = Eegeo_NEW(WeatherController)(themesService, themesUpdater);

                for(std::vector<WeatherMenuStateModel>::iterator it = weatherStates.begin(); it != weatherStates.end(); it++)
                {
                    WeatherMenuStateModel& weatherState = *it;
                    m_pMenuOptionsModel->AddItem(weatherState.GetName(),
                                                 weatherState.GetName(), "", weatherState.GetIcon(),
                                                 Eegeo_NEW(View::WeatherMenuStateOption)(weatherState, messageBus, metricsService));
                }

                m_pWeatherSelectedMessageHandler = Eegeo_NEW(WeatherSelectedMessageHandler)(*m_pWeatherController, messageBus);
            }
int main()
{
    // a JSON text
    auto text = R"(
    {
        "Image": {
            "Width":  800,
            "Height": 600,
            "Title":  "View from 15th Floor",
            "Thumbnail": {
                "Url":    "http://www.example.com/image/481989943",
                "Height": 125,
                "Width":  100
            },
            "Animated" : false,
            "IDs": [116, 943, 234, 38793]
        }
    }
    )";

    // parse and serialize JSON
    json j_complete = json::parse(text);
    std::cout << std::setw(4) << j_complete << "\n\n";


    // define parser callback
    json::parser_callback_t cb = [](int depth, json::parse_event_t event, json & parsed)
    {
        // skip object elements with key "Thumbnail"
        if (event == json::parse_event_t::key and parsed == json("Thumbnail"))
        {
            return false;
        }
        else
        {
            return true;
        }
    };
Пример #22
0
// ----------------------------------------------------------------------------
//
bool HttpRestServices::query_venue_describe( CString& response, LPCSTR data ) {
    Venue* venue = studio.getVenue();
    if ( !venue )
        return false;

    JsonBuilder json( response );

    json.startObject();
    json.add( "name", venue->getName() );
    json.add( "description", venue->getDescription() );
    json.add( "auto_blackout", venue->getAutoBlackout() );
    json.add( "dmx_port", venue->getDmxPort() );
    json.add( "dmx_packet_delay_ms", venue->getDmxPacketDelayMS() );
    json.add( "dmx_minimum_delay_ms", venue->getDmxMinimumDelayMS() );
    json.add( "audio_capture_device", venue->getAudioCaptureDevice() );
    json.add( "audio_sample_size", venue->getAudioSampleSize() );
    json.add( "audio_boost", venue->getAudioBoost() );
    json.add( "audio_boost_floor", venue->getAudioBoostFloor() );

    json.startArray( "ports" );
    for ( int i=1; i <= 12; i++ ) {
        CString com_port;
        com_port.Format( "com%d", i );
        json.add( com_port );
    }
    json.endArray( "ports" );

    json.startArray( "capture_devices" );
    for ( AudioCaptureDeviceArray::iterator it=AudioInputStream::audioCaptureDevices.begin();
            it != AudioInputStream::audioCaptureDevices.end(); ++it )
        json.add( (*it).m_friendly_name );

    json.endArray( "capture_devices" );

    json.endObject();

    return true;
}
Пример #23
0
QString	Protocol::delet(const QString& object, const QVector<QString>& v)
{
  QString	json("");

  if (v.size() < 1 || object == "")
    return json;

  json = "{";
  json += "\"Delete";
  json += object;
  json += "\": {";

  // TODO : make it generic, work only for Contact
  json += "\"Name\": \"";
  json += v[0];
  json += "\"";
  //!TODO

  json += "}";
  json += "}\n";

  return json;
}
Пример #24
0
void GetLatestVersionRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetLatestVersionRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    QMap<QString, QVariant> dict = mapFromJSON(json.data(), &error);

    if (dict.contains(kOsName)) {
        QString version = dict.value(kOsName).toString();
        qDebug("The latest version is %s", toCStr(version));
        emit success(version);
        return;
    }

    emit failed(ApiError::fromJsonError());
}
Пример #25
0
/*Main*/
int main (int argc,char* args[]){
    if(argc > 1)
    {
        if (!(archivo=fopen(args[1],"rt")))
        {
            printf("Archivo no encontrado.\n");
            exit(1);
        }
        sigLex();
        json();
        if(accept){
            fclose(archivo);
            archivo=fopen(args[1],"rt");
            sigLex();
            json_trad();
        }
    }else{
        printf("Debe pasar como parametro el path al archivo fuente.\n");
        exit(1);
    }

    return 0;
}
Пример #26
0
QVariantMap bitspace::ws::parse( QNetworkReply* reply )
{
    //TODO error handling
    QByteArray data = reply->readAll();
    qDebug() << "data:" << data;
    reply->deleteLater();
    if( !data.size() )
    {
        // TODO bad response
        qDebug() << "TODO bad response";
    }

    QString json( data );
    QJson::Parser parser;
    bool ok;
    QVariantMap result = parser.parse(data, &ok).toMap();
    if( ok )
        return result;
    else {
        // TODO error
    }
    return QVariantMap();
}
Пример #27
0
static bool parse_json(const char *data, double *plat, double *plon)
{
    RHO_MAP_TRACE1("parse_json: data=%s", data);
    json::CJSONEntry json(data);
    const char *status = json.getString("status");
    RHO_MAP_TRACE1("parse_json: status=%s", status);
    if (strcasecmp(status, "OK") != 0)
        return false;
    for (json::CJSONArrayIterator results = json.getEntry("results"); !results.isEnd(); results.next())
    {
        json::CJSONEntry item = results.getCurItem();
        if (!item.hasName("geometry"))
            continue;

        json::CJSONEntry geometry = item.getEntry("geometry");
        json::CJSONEntry location = geometry.getEntry("location");
        *plat = location.getDouble("lat");
        *plon = location.getDouble("lng");
        return true;
    }

    return false;
}
Пример #28
0
Json::Value Event::toJson() const {
    Json::Value json(Json::objectValue);
    if (id != "") {
        json["id"] = id;
    }
    if (name != "") {
        json["name"] = name;
    }
    if (countryCode != "") {
        json["countryCode"] = countryCode;
    }
    if (timezone != "") {
        json["timezone"] = timezone;
    }
    if (venue != "") {
        json["venue"] = venue;
    }
    if (openDate.tm_year > 0) {
        char buffer[25];
        strftime(buffer, 25,"%Y-%m-%dT%H:%M:%S.000Z", &openDate);
        json["openDate"] = std::string(buffer);
    }
    return json;
}
Пример #29
0
	void Notifier::EmitWithBinary(
	  uint32_t targetId,
	  const std::string& event,
	  const uint8_t* binaryData,
	  size_t binaryLen,
	  Json::Value& data)
	{
		MS_TRACE();

		static const Json::StaticString JsonStringTargetId{ "targetId" };
		static const Json::StaticString JsonStringEvent{ "event" };
		static const Json::StaticString JsonStringData{ "data" };
		static const Json::StaticString JsonStringBinary{ "binary" };

		Json::Value json(Json::objectValue);

		json[JsonStringTargetId] = Json::UInt{ targetId };
		json[JsonStringEvent]    = event;
		json[JsonStringBinary]   = true;
		json[JsonStringData]     = data;

		this->channel->Send(json);
		this->channel->SendBinary(binaryData, binaryLen);
	}
void GetDirentsRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    QString dir_id = reply.rawHeader("oid");
    if (dir_id.length() != 40) {
        emit failed(ApiError::fromHttpError(500), repo_id_);
        return;
    }
    // this extra header column only supported from v4.2 seahub
    readonly_ = reply.rawHeader("dir_perm") == "r";

    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetDirentsRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError(), repo_id_);
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    QList<SeafDirent> dirents;
    dirents = SeafDirent::listFromJSON(json.data(), &error);
    emit success(readonly_, dirents, repo_id_);
}