Esempio n. 1
0
std::unique_ptr<protocol::Value> parseJSON(const String& string) {
  if (string.isNull())
    return nullptr;
  if (string.is8Bit())
    return parseJSON(reinterpret_cast<const uint8_t*>(string.characters8()),
                     string.length());
  return parseJSON(reinterpret_cast<const uint16_t*>(string.characters16()),
                   string.length());
}
void WorldLoader::readString(std::string s){
    jsonRoot = parseJSON(s);
    JSONValue& jo = *jsonRoot;
    
    if (!serverMode){
        //Read and load the textures
        std::cout<<"Reading textures\n";
        std::vector<std::string> textures = jo["textures"].keys();
        
        for (std::vector<std::string>::iterator it=textures.begin(); it!=textures.end(); it++){
            //std::cout<<*it<<std::endl;
            tm.addTexture(*jo["textures"][*it],*it);
        }
    }
    //Read Projection details..
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(parseDouble(*jo["projection"]["fov"]),
                    parseDouble(*jo["projection"]["aspectRatio"]),
                    parseDouble(*jo["projection"]["near"]),
                    parseDouble(*jo["projection"]["far"])
    );

    //std::cout<<jo.stringise()<<std::endl;

    //load objects..
    int objectsCount = jo["objects"].length();
    //std::cout<<"Loading "<<objectsCount<<" objects."<<std::endl;
    for (int i=0; i<objectsCount; i++){
        GLObject* glo;
        if (*jo["objects"][i]["type"] == "cube"){
            glo = new GLCube();
            glo->setTextureManager(&tm);
            glo->setTexturePrefix(*jo["objects"][i]["texturePrefix"]);
            if (serverMode){
                jo["objects"][i].setMapValue("oid",parseJSON("\"" + getNewRandomOID() + "\""));
            }
            glo->setObjectID(*jo["objects"][i]["oid"]);
            
            
            //set up transformations..
            double position[3], rotation[3], size[3];
            std::istringstream  issp(*jo["objects"][i]["position"]),
                                isso(*jo["objects"][i]["orientation"]),
                                isss(*jo["objects"][i]["dimensions"]);
            
            issp>>position[0]>>position[1]>>position[2];
            isso>>rotation[0]>>rotation[1]>>rotation[2];
            isss>>size[0]>>size[1]>>size[2];
            glo->setPosition(position[0], position[1], position[2]);
            glo->setRotation(rotation[0], rotation[1], rotation[2]);
            glo->setSize(size[0], size[1], size[2]);
        }else{
int main(){
    std::ifstream file("world.json");
    std::stringstream ss;
    ss<<file.rdbuf();
    file.close();
    
    JSONValue& jv = *parseJSON(ss.str());
    (jv["objects"][0].getMap())["oid"] = parseJSON("\"" "hellow"  "\"");
    //(jv["textures"].getMap())["temp"] = parseJSON("\"HELLOW\"");
    std::cout<<jv.stringise(true)<<std::endl;
    std::cout<<*jv["objects"][0]["oid"]<<std::endl;
    
    //std::cout<<"Test: "<<jv["objects"][1]["transformations"][0]["type"].get()<<std::endl;
}
Esempio n. 4
0
int main()
{
    int size;    // 문서 크기

    // 파일에서 JSON 문서를 읽음, 문서 크기를 구함
    char *doc = readFile("example.json", &size);
    if (doc == NULL)
        return -1;

    JSON json = { 0, };    // JSON 구조체 변수 선언 및 초기화

    parseJSON(doc, size, &json);    // JSON 문서 파싱

    printf("Title: %s\n", json.tokens[1].string);        // 토큰에 저장된 문자열 출력(Title)
    printf("Year: %d\n", (int)json.tokens[3].number);    // 토큰에 저장된 숫자 출력(Year)
    printf("Runtime: %d\n", (int)json.tokens[5].number); // 토큰에 저장된 숫자 출력(Runtime)
    printf("Genre: %s\n", json.tokens[7].string);        // 토큰에 저장된 문자열 출력(Genre)
    printf("Director: %s\n", json.tokens[9].string);     // 토큰에 저장된 문자열 출력(Director)
    printf("Actors:\n");
    printf("  %s\n", json.tokens[11].string);            // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[12].string);            // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[13].string);            // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[14].string);            // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[15].string);            // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("imdbRating: %f\n", json.tokens[17].number);  // 토큰에 저장된 숫자 출력(imdbRating)

    freeJSON(&json);    // json 안에 할당된 동적 메모리 해제

    free(doc);    // 문서 동적 메모리 해제

    return 0;
}
Esempio n. 5
0
void Sequence1::loadFromFile(const QString &fname) {
	d->m_commands.clear();
	
	QMap<QString,QVariant> simblocks=parseJSON(read_text_file(fname)).toMap();
	
	QList<QVariant> rf_waveforms=simblocks["rf_waveforms"].toList();
	QList<QVariant> blocks=simblocks["blocks"].toList();
	
	{
		SimCommand CC;
		CC.command="initialize";
		d->m_commands << CC;
	}
	for (int i=0; i<rf_waveforms.count(); i++) {
		SimCommand CC;
		CC.command="add_RF_waveform";
		CC.data=rf_waveforms[i].toMap();
		d->m_commands << CC;
	}
	for (int i=0; i<blocks.count(); i++) {
		SimCommand CC;
		CC.command="run_block";
		CC.data=blocks[i].toMap();
		d->m_commands << CC;
	}
	{
		SimCommand CC;
		CC.command="finalize";
		d->m_commands << CC;
	}
}
Esempio n. 6
0
void collectUniqueResource(const OCClientResponse * clientResponse)
{
    char * sid = NULL;
    char ** uri = NULL;
    int totalRes = 0;

    if(parseJSON(clientResponse->resJSONPayload, & sid, & uri, &totalRes)
            != OC_STACK_OK)
    {
        OC_LOG(ERROR, TAG, "Error while parsing JSON payload in OCClientResponse");
        OICFree(sid);
        OICFree(uri);
        return;
    }

    int i;
    for(i = 0; i < totalRes; i++)
    {
        if(insertResource(sid, uri[i], clientResponse) == 1)
        {
            printf("%s%s%s%s\n",sid, ":", uri[i], " is new");
            printResourceList();
            queryResource();
        }
        else
        {
            printf("%s%s%s%s\n\n",sid, ":", uri[i], " has been seen before");
        }
    }

    OICFree(sid);
    OICFree(uri);
 }
void EntityMap::loadData(QString ref)
{
    json = parseJSON(ref);
    QJsonArray enemyList = json["enemyList"].toArray();
    if(enemyList.size() > 0){
        for(int i = 0; i < enemyList.size(); i++){
            QJsonObject je = enemyList[i].toObject();

            EnemyEntry entry;
            entry.spawnTrigger = je["spawnTrigger"].toInt();
            entry.enemyClass = je["enemyClassName"].toString();
            entry.polarity = je["polarity"].toInt() % 2 == 0 ? WHITE : BLACK;
            entry.spawnX = je["spawnX"].toInt();
            entry.spawnY = je["spawnY"].toInt();

            QJsonArray pathList = je["paths"].toArray();
            for (int j = 0; j < pathList.size(); ++j) {
                QJsonArray path = pathList.at(j).toArray();
                entry.paths.append(Point(path.at(0).toInt(),path.at(1).toInt()));
            }

            entry.spawnRef = je["spawnRef"].toString();

            enemies.add(entry);

        }
    }
}
Esempio n. 8
0
bool registerClient(char *loc)
{
   char *registerURL=NULL;
   asprintf(&registerURL,"%s/register?uuid=%s&mac=%s&fw_version=%s&arch=%s&platform=%s&ip=%s",
         ph->location,
         // TODO : More generic!
         ph->uuid,
         ht_get_simple(ph->configFlagsMap,"W_MAC"),
         ht_get_simple(ph->configFlagsMap,"VERSION"),
         ht_get_simple(ph->configFlagsMap,"WALLY_ARCH"),
         ht_get_simple(ph->configFlagsMap,"WALLY_PLATFORM"),
         ht_get_simple(ph->configFlagsMap,"W_IPADDR"));
   slog(DEBUG,DEBUG,"RegURL : %s",registerURL);
 
   registerMap = malloc(sizeof(hash_table));
   ht_init(registerMap, HT_KEY_CONST | HT_VALUE_CONST, 0.05);

   ph->registered = parseJSON(registerMap,url_call(registerURL),NULL);
   if(registerURL){
      free(registerURL);
   }
   if(ph->registered){
         asprintf(&commandURL,"%s/command?uuid=%s", ph->location, ph->uuid);
         commandURL=replace(commandURL,"/register?","/command?");
   } else {
         commandURL=NULL;
   }
   slog(DEBUG,DEBUG,"CmdURL : %s",commandURL);

   return ph->registered;
}
Esempio n. 9
0
void GetAvatarRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetAvatarRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    const char *avatar_url = json_string_value(json_object_get(json.data(), "url"));

    if (!avatar_url) {
        qDebug("GetAvatarRequest: no 'url' value in response\n");
        emit failed(ApiError::fromJsonError());
        return;
    }

    QString url = QUrl::fromPercentEncoding(avatar_url);

    fetch_img_req_ = new FetchImageRequest(url);

    connect(fetch_img_req_, SIGNAL(failed(const ApiError&)),
            this, SIGNAL(failed(const ApiError&)));
    connect(fetch_img_req_, SIGNAL(success(const QImage&)),
            this, SIGNAL(success(const QImage&)));
    fetch_img_req_->send();
}
Esempio n. 10
0
void MyDrawWindowCallback(
                          XPLMWindowID         inWindowID,
                          void *               inRefcon)
{
	int	left, top, right, bottom;
	float color[] = { 0.0, 0.0, 0.0 };
	
	XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);
    
    if (getData != NULL) {
        //if (newData)
            parseJSON();
        
        if (message != NULL) {
        
            XPLMDrawTranslucentDarkBox(left, top, right, bottom);
        
            /*char out[512];
            sprintf(out, "SIZE: %d\n", (int) sizeof(message));
            XPLMDebugString(out);
        
            char m[sizeof(message)];
            strcpy(m, message[1], sizeof(message) - 1);
            m[sizeof(message) - 1] = '\0';*/
            
            char *m = strndup(message+29, 29+50);
        
            XPLMDrawString(color, left + 50, top - 20, m, NULL, xplmFont_Basic);
        
            // TODO: start thread to reset getData after x seconds and hide the window
        }
    }
}
Esempio n. 11
0
static void test_string(void)
{
    JSON json = parseJSON(data, data+sizeof(data));
    JSON child = JSON_get(json, "app");
    assert(JSON_isValid(child));
    assert(JSON_type(child) == JSON_Array);
    assert(JSON_length(child) == 3);
    JSONArray *a;
    JSON *I, *E;
    int i = 0;

    JSON_ARRAY_EACH(child, a, I, E) {
        assert(JSON_isValid(JSON_get(*I, "name")));
        assert(JSON_isValid(JSON_get(*I, "line")));
        assert(JSON_isValid(JSON_get(*I, "version")));
        assert(JSON_isValid(JSON_get(*I, "flag")));
        size_t len;
        const char *name = JSON_getString(*I, "name", &len);
        int   line = JSON_getInt(*I, "line");
        double ver  = JSON_getDouble(*I, "version");
        assert(len == strlen(names[i]) && strncmp(name, names[i], len) == 0);
        assert(line == lines[i]);
        assert(ver  == versions[i]);
        fprintf(stderr, "%s %d %f\n", name, line, ver);
        i++;
    }
Esempio n. 12
0
int main()
{
    int size;    // 문서 크기

    // 파일에서 JSON 문서를 읽음, 문서 크기를 구함
    char *doc = readFile("example.json", &size);
    if (doc == NULL)
        return -1;

    JSON json = { 0, };    // JSON 구조체 변수 선언 및 초기화

    parseJSON(doc, size, &json);    // JSON 문서 파싱

    printf("Title: %s\n", json.tokens[1].string);    // 토큰에 저장된 문자열 출력(Title)
    printf("Genre: %s\n", json.tokens[3].string);    // 토큰에 저장된 문자열 출력(Genre)
    printf("Director: %s\n", json.tokens[5].string); // 토큰에 저장된 문자열 출력(Director)
    printf("Actors:\n");
    printf("  %s\n", json.tokens[7].string);         // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[8].string);         // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[9].string);         // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[10].string);        // 토큰에 저장된 문자열 출력(Actors 배열의 요소)
    printf("  %s\n", json.tokens[11].string);        // 토큰에 저장된 문자열 출력(Actors 배열의 요소)

    freeJSON(&json);    // json 안에 할당된 동적 메모리 해제

    free(doc);    // 문서 동적 메모리 해제

    return 0;
}
void GetFileUploadedBytesRequest::requestSuccess(QNetworkReply &reply)
{
    QString accept_ranges_header = reply.rawHeader("Accept-Ranges");
    // printf ("accept_ranges_header = %s\n", toCStr(accept_ranges_header));
    if (accept_ranges_header != "bytes") {
        // Chunked uploading is not supported on the server
        emit success(false, 0);
        return;
    }

    json_error_t error;
    json_t* root = parseJSON(reply, &error);
    if (!root) {
        qWarning("GetFileUploadedBytesRequest: 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);
    quint64 uploaded_bytes = dict["uploadedBytes"].toLongLong();
    // printf ("uploadedBytes = %lld\n", uploaded_bytes);
    emit success(true, uploaded_bytes);
}
Esempio n. 14
0
void GetDefaultRepoRequest::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("exists")) {
        emit failed(ApiError::fromJsonError());
        return;
    }

    bool exists = dict.value("exists").toBool();
    if (!exists) {
        emit success(false, "");
        return;
    }

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

    QString repo_id = dict.value("repo_id").toString();

    emit success(true, repo_id);
}
Esempio n. 15
0
void FileSearchRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t* root = parseJSON(reply, &error);
    if (!root) {
        qWarning("FileSearchResult: failed to parse jsn:%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("results")) {
        emit failed(ApiError::fromJsonError());
        return;
    }
    QList<QVariant> results = dict["results"].toList();
    std::vector<FileSearchResult> retval;
    Q_FOREACH(const QVariant& result, results)
    {
        FileSearchResult tmp;
        QMap<QString, QVariant> map = result.toMap();
        if (map.empty())
            continue;
        tmp.repo_id = map["repo_id"].toString();
        tmp.repo_name = RepoService::instance()->getRepo(tmp.repo_id).name;
        tmp.name = map["name"].toString();
        tmp.oid = map["oid"].toString();
        tmp.last_modified = map["last_modified"].toLongLong();
        tmp.fullpath = map["fullpath"].toString();
        tmp.size = map["size"].toLongLong();
        retval.push_back(tmp);
    }
Esempio n. 16
0
void ServerInfoRequest::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);

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

    ServerInfo ret;

    if (dict.contains("version")) {
        ret.parseVersionFromString(dict["version"].toString());
    }

    if (dict.contains("features")) {
        ret.parseFeatureFromStrings(dict["features"].toStringList());
    }

    if (dict.contains("desktop-custom-logo")) {
        ret.customLogo = dict["desktop-custom-logo"].toString();
    }

    if (dict.contains("desktop-custom-brand")) {
        ret.customBrand = dict["desktop-custom-brand"].toString();
    }

    emit success(account_, ret);
}
Esempio n. 17
0
void GetEventsRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetEventsRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    bool more = false;
    int more_offset = -1;

    json_t* array = json_object_get(json.data(), "events");
    std::vector<SeafEvent> events = SeafEvent::listFromJSON(array, &error);

    more = json_is_true(json_object_get(json.data(), "more"));
    if (more) {
        more_offset = json_integer_value(json_object_get(json.data(), "more_offset"));
    }

    emit success(events, more_offset);
}
Esempio n. 18
0
static kbool_t ParseJson(KonohaContext *kctx, struct JsonBuf *jsonbuf, const char *text, size_t length, KTraceInfo *trace)
{
	JSON json = parseJSON((JSONMemoryPool *)(JSONAPI JsonHandler), text, text + length);
	if(IsError(json.val)) {
		KLIB KRuntime_raise(kctx, KException_("InvalidJsonText"), SoftwareFault, NULL, trace->baseStack);
	}
	jsonbuf->json_i = json.bits;
	return jsonbuf->json_i != 0;
}
Esempio n. 19
0
 // WorkerInspectorProxy::PageInspector implementation
 virtual void dispatchMessageFromWorker(const String& message) override
 {
     RefPtr<JSONValue> value = parseJSON(message);
     if (!value)
         return;
     RefPtr<JSONObject> messageObject = value->asObject();
     if (!messageObject)
         return;
     m_frontend->dispatchMessageFromWorker(m_id, messageObject);
 }
Esempio n. 20
0
//## @Static JSON JSON.parse(String str);
static KMETHOD kJSON_parse(KonohaContext *kctx, KonohaStack *sfp)
{
	const char *text = S_text(sfp[1].asString);
	JSON json = parseJSON(text, text+S_size(sfp[1].asString));
	if(!json.bits) {
		/* FIXME Error Handling */
		KReturnDefaultObjectValue();
	}
	KReturn(NewJsonObject(kctx, sfp, json));
}
Esempio n. 21
0
PassRefPtr<JSONObject> RemoteObjectIdBase::parseInjectedScriptId(const String& objectId)
{
    RefPtr<JSONValue> parsedValue = parseJSON(objectId);
    if (!parsedValue || parsedValue->type() != JSONValue::TypeObject)
        return nullptr;

    RefPtr<JSONObject> parsedObjectId = parsedValue->asObject();
    bool success = parsedObjectId->getNumber("injectedScriptId", &m_injectedScriptId);
    if (success)
        return parsedObjectId.release();
    return nullptr;
}
String InjectedScript::objectIdToObjectGroupName(const String& objectId) const
{
    RefPtr<JSONValue> parsedObjectId = parseJSON(objectId);
    if (!parsedObjectId)
        return String();
    RefPtr<JSONObject> object;
    if (!parsedObjectId->asObject(&object))
        return String();
    int boundId = 0;
    if (!object->getNumber("id", &boundId))
        return String();
    return m_native->groupName(boundId);
}
void InjectedScript::releaseObject(const String& objectId)
{
    RefPtr<JSONValue> parsedObjectId = parseJSON(objectId);
    if (!parsedObjectId)
        return;
    RefPtr<JSONObject> object;
    if (!parsedObjectId->asObject(&object))
        return;
    int boundId = 0;
    if (!object->getNumber("id", &boundId))
        return;
    m_native->unbind(boundId);
}
Esempio n. 24
0
extern bool texture_loadPackingInfo(Texture_t *aTexture, const char *aPath)
{
    char *jsonInput;
    util_readFile(aPath, NULL, &jsonInput);
    dynamo_assert(jsonInput != NULL, "No file at %s", aPath);
    Dictionary_t *info = parseJSON(jsonInput);
    free(jsonInput);
    dynamo_assert(info != NULL && dict_get(info, "frames") != NULL, "Could not load texture packing info from %s", aPath);
    
    aTexture->subtextures = obj_retain(dict_get(info, "frames"));
    
    return true;
}
Esempio n. 25
0
static void test_file(const char *file)
{
    fprintf(stderr, "--- {{ test %s --- \n", file);
    size_t len;
    char *str = loadFile(file, &len);
    JSON json = parseJSON(str, str+len);
    size_t json_len;
    char *json_s = JSON_toStringWithLength(json, &json_len);
    fprintf(stderr, "'%s'\n", json_s);
    fprintf(stderr, "\n--- }} test %s --- \n", file);
    free(json_s);
    JSON_free(json);
    free(str);
}
void ApplicationUpdateChecker::parseWebServiceReply(QNetworkReply *reply)
{
    m_checkOk = false;
    if (reply->error() == QNetworkReply::NoError)
    {
        // Punt d'entrada per el unit testing (readReplyData)
        parseJSON(readReplyData(reply));
    }
    else
    {
        ERROR_LOG(QString("Error buscant noves versions al servidor. La resposta del webservice és del tipus ") +
                  QString::number(reply->error()) + QString(": ") + reply->errorString());
        m_errorDescription = tr("Error connecting to the server. Server response is: %1").arg(reply->errorString());
    }
}
Esempio n. 27
0
void CreateSubrepoRequest::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);
    QMap<QString, QVariant> dict = mapFromJSON(json.data(), &error);

    emit success(dict["sub_repo_id"].toString());
}
Esempio n. 28
0
void GetStarredFilesRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetStarredFilesRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    std::vector<StarredFile> files = StarredFile::listFromJSON(json.data(), &error);
    emit success(files);
}
Esempio n. 29
0
void GetCommitDetailsRequest::requestSuccess(QNetworkReply& reply)
{
    json_error_t error;
    json_t *root = parseJSON(reply, &error);
    if (!root) {
        qDebug("GetCommitDetailsRequest: failed to parse json:%s\n", error.text);
        emit failed(ApiError::fromJsonError());
        return;
    }

    QScopedPointer<json_t, JsonPointerCustomDeleter> json(root);

    CommitDetails details = CommitDetails::fromJSON(json.data(), &error);

    emit success(details);
}
void GetSmartLinkRequest::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* smart_link =
        json_string_value(json_object_get(json.data(), "smart_link"));

    emit success(smart_link);
}