• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ csjson::Reader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中csjson::Reader的典型用法代码示例。如果您正苦于以下问题:C++ Reader类的具体用法?C++ Reader怎么用?C++ Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Reader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: initWithSkillId

void SkillsInfo::initWithSkillId(int skillId){
    CSJson::Reader reader;
    CSJson::Value root;
    CCString  * str= CCString::createWithContentsOfFile(SKILLJSONNAME);
    CCLOG("%s",str->getCString());
    if (reader.parse(str->getCString(), root)) {
        CSJson::Value data=root["data"];
        CSJson::Value row=data["row"];
        char skillname[20]="";
        sprintf(skillname, "%d",skillId);
        CSJson::Value skilldata=data[skillname];
        m_skillTypeId=skilldata[SKILLTYPE].asInt();
        m_skillCrp=skilldata[SKILLCRP].asInt();
        m_skillCri=skilldata[SKILLCRI].asInt();
        m_skillScript=skilldata[SKILLSCRIPT].asString().c_str();
        m_skillBuffid=skilldata[SKILLBUFFID].asInt();
        gold=skilldata[SKILLGOLD].asInt();
        nextid=skilldata[SKILLNEXTID].asInt();
        moveeffect=skilldata[SKILLMOVEEFFECT].asInt();
        m_skillTimes=skilldata[SKILLTIMES].asFloat();
        m_skillRange=skilldata[SKILLRANGES].asInt();
        CCLog("%d",m_skillRange);
        attackeffect=skilldata[SKILLATTACKEFFECT].asInt();
        passiveeffect=skilldata[SKILLPASSIVEEFFECT].asInt();
        m_skillCounts=skilldata[SKILLCOUNTS].asInt();
        m_skillName=skilldata[SKILLNAME].asString().c_str();
    }
}
开发者ID:9miao,项目名称:Pocket-Warriors,代码行数:28,代码来源:SkillInfo.cpp


示例2: recvLoginData

void LoginScene::recvLoginData()
{
    Message * msg= (Message *)GameData::shareGameData()->dic->objectForKey(1001);
    if(msg){
        this->unschedule(schedule_selector(LoginScene::recvLoginData));
        GameData::shareGameData()->dic->removeObjectForKey(1001);
        CSJson::Reader reader;
        CSJson::Value root;
        if (reader.parse(msg->getContent(), root))
        {
            int uid = root["uid"].asInt();
            if (uid > 0)
            {
                GameData::shareGameData()->userID=uid;
                CCScene * scene= MainLayer::scene();
                //  this->addChild(scene,10);
                CCDirector::sharedDirector()->replaceScene(scene);
            }
            else
            {
                CCMessageBox(UiLanguage::shareLanguage()->get("password_error"), UiLanguage::shareLanguage()->get("msgbox_notice"));
            }
        }
    }

}
开发者ID:aquariusgx,项目名称:coc,代码行数:26,代码来源:LoginScene.cpp


示例3: initBag

void shop::initBag(){
    CSJson::Reader reader;
    CSJson::Value root;
    if (reader.parse(GameData::shareGameData()->bagData, root)) {
        bool result=root["result"].asBool();
        if (result) {
            CSJson::Value data;
            data=root["data"];
            for (int i=0; i<data.size(); i++) {
                CCLog("%d",data[i].asInt());
                if (i<12) {
                    buySkill[i]=data[i].asInt();
                    arrTag=i;
                    UIButton * btn= dynamic_cast<UIButton *>(layer->getWidgetByTag(9+i));
                    btn->addPushDownEvent(this, coco_pushselector(shop::touchBeganEvent0));
                    btn->addMoveEvent(this, coco_moveselector(shop::touchMovedEvent0));
                    btn->addReleaseEvent(this, coco_moveselector(shop::touchEndedEvent0));
                    
                    char name[20]="";
                    sprintf(name, "skill-%02d.png",i+1);
                    btn->loadTextures(name, name, name);
                    btn->setVisible(true);
                }
            }
        }
    }
}
开发者ID:hycxa,项目名称:crossapp-demo,代码行数:27,代码来源:shop.cpp


示例4: readDescription

void CJsonPacker::readDescription(const char *pszDescription)
{
    CSJson::Reader cReader;
    if (pszDescription && *pszDescription)
    {
        std::string strValue = pszDescription;
        cReader.parse(strValue, m_cValue, false);
    }
}
开发者ID:haolin,项目名称:haolin.github.io,代码行数:9,代码来源:CJsonPacker.cpp


示例5: getJsonFromString

bool CJsonHelper::getJsonFromString(const char* pszData,CSJson::Value& Val)
{
	CSJson::Reader reader;  
	CSJson::Value jsValue;
	//这里将pBuffer的值付给jsValue值
	bool parseRet = reader.parse(pszData, jsValue, false);
	Val = jsValue;
	//CCAssert(parseRet, "Read JsonData Error~!!!!!!!!!");
	return parseRet; 
}
开发者ID:anzhongliu,项目名称:SmallGame_Cocos2dx,代码行数:10,代码来源:JsonHelper.cpp


示例6: onResponseJsonNoCache

void CommonHttpResponseCallBack::onResponseJsonNoCache(CAHttpClient* client, CAHttpResponse* response)
{
    CommonHttpManager::getInstance()->stopActivityIndicatorView();
    
    CC_RETURN_IF(!m_pSelectorJson);
    if (response->isSucceed())
    {
        std::string data(response->getResponseData()->begin(), response->getResponseData()->end());
        if (!data.empty())
        {
            if (CAViewController* viewController = dynamic_cast<CAViewController*>(m_pTarget))
            {
                CC_RETURN_IF(viewController->isViewRunning() == false);
            }
            
            CCLog("\n \n \n---------HttpResponse--json---------\n<<<\n%s\n>>>\n--------------END--------------\n \n \n",data.c_str());
            
            CSJson::Reader read;
            CSJson::Value root;
            bool succ = read.parse(data, root);
            if (succ == false)
            {
                CCLog("GetParseError \n");
            }
            
            if (m_pTarget)
            {
                (m_pTarget->*m_pSelectorJson)(HttpResponseSucceed, root);
            }
        }
        else
        {
            CSJson::Value root;
            if (m_pTarget)
            {
                (m_pTarget->*m_pSelectorJson)(HttpResponseFaild, root);
            }
        }
        
    }
    else
    {
        CSJson::Value root;
        if (m_pTarget)
        {
            (m_pTarget->*m_pSelectorJson)(HttpResponseFaild, root);
        }
    }
}
开发者ID:Super-Man,项目名称:CrossApp,代码行数:49,代码来源:CommonHttpManager.cpp


示例7: getAddressBook

vector<CAAddressBookRecord> getAddressBook()
{
    if (_addressBookArr.size() > 0 )
    {
        return _addressBookArr;
    }
    
    CSJson::Reader read;
    CSJson::Value root;
    
    if (read.parse(ShowAddress(), root))
    {
        CSJson::Value personlist;
        personlist = root["person"];
        
        for (int i=0; i<personlist.size(); i++)
        {
            CSJson::Value person;
            person = personlist[i];
            CAAddressBookRecord addrec;
            
            addrec.fullname = person["name"].asString();
            
            CSJson::Value phonelist = person["phone"];
            
            for (int i=0; i<1; i++)
            {
                addrec.phoneNumber = phonelist[i].asString();
            }
            
            addrec.email = person["email"].asString();
            
            addrec.street = person["address_street"].asString();
            
            addrec.province = person["address_region"].asString();
            
            addrec.city = person["address_city"].asString();
            
            addrec.nickname = person["nickname"].asString();
            
            addrec.zip = person["address_postCode"].asString();
            
            _addressBookArr.push_back(addrec);
            
        }
    }

    return _addressBookArr;
}
开发者ID:boaass,项目名称:CrossApp,代码行数:49,代码来源:CADevice.cpp


示例8: createCAWidgetWithJsonFile

CCDictionary* CAUIHelper::createCAWidgetWithJsonFile(const char *filename)
{
    std::string fullpath= CCFileUtils::sharedFileUtils()->fullPathForFilename(filename);
    CCLog("%s",fullpath.c_str());
    unsigned long size = 0;
    char *des = (char*) CCFileUtils::sharedFileUtils()->getFileData(filename, "r", &size);
    CSJson::Reader reader;
    CSJson::Value root;
    CSJson::Value description;
    CSJson::Value rect;
    CCObject *ui = new CCObject();
    
    if (!reader.parse(des, root))
    {
        CCLog("error");
        return NULL;
    }
    CCLog("%s",des);
    for (int i = 0; i<root.size(); i++)
    {
        description = root[i];
        CAType type = (CAType)description["typeMode"].asInt();
        rect = description["rect"];
        std::string name = description["name"].asString();
        float width = rect["width"].asFloat();
        float height = rect["height"].asFloat();
        float x = rect["x"].asFloat();
        float y = rect ["y"].asFloat();
        CCRect uirect = CCRectMake(x, y, width, height);
        // ui=CAButton::createWithFrame(CCRectMake(x, y, width, height));
        if (type == CATypeButton)
        {
            ui = addButton(description, uirect);
        }
        else if(type == CATypeLabel)
        {
            ui = addLabel(description, uirect);
        }
        else if(type == CATypeImage)
        {
            
        }
        m_UIDictionary->setObject(ui, name.c_str());
        
    }
    ui->release();
    return m_UIDictionary;
}
开发者ID:DeltaYang,项目名称:CrossApp,代码行数:48,代码来源:CAUIHelper.cpp


示例9: setData

void GameOver::setData(const char *data){
    CCLog("%s",data);
    CSJson::Reader reader;
    CSJson::Value root;
    if(reader.parse(data, root)){
        CSJson::Value sData;
        sData=root["data"];
        CCLog("%d",sData["battleResult"].asInt());
        CSJson::Value setData;
        setData=sData["setData"];
        int star=setData["star"].asInt();
        char starnum[10]="";
        sprintf(starnum, "星级为:%d",star);
        //label1->setString(starnum);
    }
}
开发者ID:hycxa,项目名称:crossapp-demo,代码行数:16,代码来源:GameOver.cpp


示例10: releaseJson

void CAAddressManager::releaseJson(const char* json)
{
    CSJson::Reader read;
    CSJson::Value root;
    if (read.parse(json, root))
    {
        CSJson::Value personlist;
        
        personlist = root["person"];
        for (int i=0; i<personlist.size(); i++)
        {
            CSJson::Value person;
            person = personlist[i];
            CAAddressBookRecord *addrec = new CAAddressBookRecord();

            addrec->fullname = person["name"].asString();
            
            CSJson::Value phonelist = person["phone"];
            for (int i=0; i<1; i++) {
                

                    addrec->phoneNumber = phonelist[i].asString();
                    
                
            }

            addrec->email = person["email"].asString();

            addrec->street = person["address_street"].asString();

            addrec->province = person["address_region"].asString();

            addrec->city = person["address_city"].asString();

            addrec->nickname = person["nickname"].asString();
            
            addrec->zip = person["address_postCode"].asString();

            _addressBookArr.push_back(addrec);

        }
    }
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:43,代码来源:CAAddressManager.cpp


示例11: Load

int RemoteUser::Load(const char *path) {
  char buf[512];
  memset(buf, 0, sizeof(buf));
  CAReadFile("userdata", buf, 512);
  if (strlen(buf) == 0) {
    CCLOG("read userdata faild.");
    return -1;
  }

  CSJson::Reader reader;
  CSJson::Value value;
  if (!reader.parse(std::string((char *)buf), value, false)) {
    CCLOG("parse %s error", path);
    return -1;
  }

  userid_ = value.get("userid", "").asString();
  CCLOG("userid %s", userid_.c_str());
  return 0;
}
开发者ID:f17qh,项目名称:crazyass,代码行数:20,代码来源:user.cpp


示例12: load

bool TouchGrabber::load(const std::string &filename)
{
    std::string doc = Assets::readTextFile(filename,false);
    CSJson::Reader reader;
    CSJson::Value root;
    if (reader.parse(doc, root) == false) {
        CCLOGERROR("ERROR: can't parse JSON touch data file %s",filename.c_str());
        return false;
    }
    mTouchesRecVector.clear();
    for (const CSJson::Value &value : root) {
        TouchRecord rec;
        rec.x = value["x"].asFloat();
        rec.y = value["y"].asFloat();
        rec.event = (TouchEvent)value["event"].asInt();
        rec.time = value["time"].asFloat();
        mTouchesRecVector.push_back(rec);
    }
    return true;
}
开发者ID:xoraphics,项目名称:yummyjump,代码行数:20,代码来源:touchgrabber.cpp


示例13: initLoadSkill

void shop::initLoadSkill(){
    CSJson::Reader reader;
    CSJson::Value root;
    if (reader.parse(GameData::shareGameData()->szData, root)) {
        CSJson::Value data;
        
        data=root["data"];
        int skill1=data["skill_1"].asInt();
        int skill2=data["skill_2"].asInt();
        if (skill1!=0) {
            UIButton * btn= dynamic_cast<UIButton *>(layer->getWidgetByTag(33));
            btn->loadTextures("skill-01.png", "skill-01.png", "skill-01.png");
            btn->setVisible(true);
            
        }else if(skill2!=0){
            UIButton * btn= dynamic_cast<UIButton *>(layer->getWidgetByTag(34));
            btn->loadTextures("skill-02.png", "skill-02.png", "skill-02.png");
        }
        
       // CCLog()
    }
}
开发者ID:hycxa,项目名称:crossapp-demo,代码行数:22,代码来源:shop.cpp


示例14: _onLeaderboardLoaded

void OnlineController::_onLeaderboardLoaded(CCHttpClient* client, CCHttpResponse* response)
{
    if (response->isSucceed())
    {
        CCLog("== leaderboard loading succseeded");
        m_leaderboardEntries.clear();

        CSJson::Reader reader;
        std::vector<char>* data = response->getResponseData();
        CSJson::Value value;
        const char* begin = &(*data)[0];
        const char* end = begin + data->size();
        reader.parse(begin, end, value, false);
        if (value.isArray())
        {
            for (CSJson::ArrayIndex i = 0; i < value.size(); ++i)
            {
                const CSJson::Value jsonEntry = value[i];
                LeaderboardEntry entry;
                entry.name = jsonEntry.get("display_name", "").asCString();
                entry.score = atoi(jsonEntry.get("score", "0").asCString());
                entry.rank = atoi(jsonEntry.get("rank", "0").asCString());
                m_leaderboardEntries.push_back(entry);
            }
        }
        SharedEventController::Instance().onLeaderboardLoaded();
        // schedule refresh
        CCDirector::sharedDirector()->getScheduler()->
            scheduleSelector(SEL_SCHEDULE(&OnlineController::_loadLeaderboard), this, s_leaderboardRefreshInterval, 0, 0, false);
    }
    else
    {
        CCLog("== leaderboard loading failed. Error: %s", response->getErrorBuffer());
        // schedule retry
        CCDirector::sharedDirector()->getScheduler()->
            scheduleSelector(SEL_SCHEDULE(&OnlineController::_loadLeaderboard), this, s_leaderboardRetryInterval, 0, 0, false);
    }
}
开发者ID:timur-losev,项目名称:HungryChameleon,代码行数:38,代码来源:OnlineController.cpp


示例15: onResponseJson

void CommonHttpResponseCallBack::onResponseJson(CAHttpClient* client, CAHttpResponse* response)
{
    CommonHttpManager::getInstance()->stopActivityIndicatorView();
    
    CC_RETURN_IF(!m_pSelectorJson);
    if (response->isSucceed())
    {
        std::string data(response->getResponseData()->begin(), response->getResponseData()->end());
        if (!data.empty())
        {
            localStorageSetItem(MD5(m_sUrl).md5().c_str(), data.c_str());
            
            if (CAViewController* viewController = dynamic_cast<CAViewController*>(m_pTarget))
            {
                CC_RETURN_IF(viewController->isViewRunning() == false);
            }
            
            //CCLog("\n \n \n---------HttpResponse--json---------\n<<<\n%s\n>>>\n--------------END--------------\n \n \n",data.c_str());
            
            CSJson::Reader read;
            CSJson::Value root;
            bool succ = read.parse(data, root);
            if (succ == false)
            {
                CCLog("GetParseError \n");
            }
            
            if (m_pTarget)
            {
                (m_pTarget->*m_pSelectorJson)(HttpResponseSucceed, root);
            }
        }
        else
        {
            if (CAViewController* viewController = dynamic_cast<CAViewController*>(m_pTarget))
            {
                CC_RETURN_IF(viewController->isViewRunning() == false);
            }
            
            CSJson::Value root;
            if (m_pTarget)
            {
                (m_pTarget->*m_pSelectorJson)(HttpResponseFaild, root);
            }
        }
        
    }
    else
    {
        if (CAViewController* viewController = dynamic_cast<CAViewController*>(m_pTarget))
        {
            CC_RETURN_IF(viewController->isViewRunning() == false);
        }
        
        const char* data = localStorageGetItem(MD5(m_sUrl).md5().c_str());

        do
        {
            CC_BREAK_IF(data == NULL);
            CSJson::Reader read;
            CSJson::Value root;
            bool succ = read.parse(data, root);
            if (succ == false)
            {
                CCLog("GetParseError \n");
                break;
            }
            
            if (m_pTarget)
            {
                (m_pTarget->*m_pSelectorJson)(HttpResponseSucceed, root);
            }
            return;
        }
        while (0);
        
        CSJson::Value root;
        if (m_pTarget)
        {
            (m_pTarget->*m_pSelectorJson)(HttpResponseFaild, root);
        }
    }
}
开发者ID:Super-Man,项目名称:CrossApp,代码行数:83,代码来源:CommonHttpManager.cpp



注:本文中的csjson::Reader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ csmdoc::Document类代码示例发布时间:2022-05-31
下一篇:
C++ cryptopp::Integer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap