当前位置: 首页>>代码示例>>C++>>正文


C++ Reader::getFormatedErrorMessages方法代码示例

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


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

示例1: convertJsonToTag

Tag TagDB::convertJsonToTag(string jsonString) {
    Tag itemReturn;
    Json::Value root;
    Json::Reader reader;
    bool parsedSuccess = reader.parse(jsonString, root, false);
    if (not parsedSuccess) {
        // Report failures and their locations in the document.
        cout << "Failed to parse JSON" << endl
                << reader.getFormatedErrorMessages()
                << endl;
        poco_error_f1(*logger, "convertJsonToTag: Failed to parse JSON %s", reader.getFormatedErrorMessages());
        return itemReturn;
    }
    //Json::Value tagID = root["tagID"];
    Json::Value tagName = root["tagName"];
    Json::Value viewCounts = root["viewCounts"];
    Json::Value dateAdd = root["dateAdd"];
    Json::Value dateUpdate = root["dateUpdate"];

    //itemReturn.tagID = tagID.asString();
    itemReturn.tagName = tagName.asString();
    itemReturn.viewCounts = viewCounts.asInt();
    itemReturn.dateAdd = dateAdd.asString();
    itemReturn.dateUpdate = dateUpdate.asString();
    //poco_information(*logger, "convertJsonToTag: Convert from Json to Tag successfull");
    return itemReturn;
}
开发者ID:mappcenter,项目名称:lazyboys-pro,代码行数:27,代码来源:TagDB.cpp

示例2: Read

bool Ori::Read (
      const std::string &camera_filename, int camera_id,
      const std::string &panoramic_filename, int panoramic_id
)
{
    Json::Value camera;   // will contains the camera root value after parsing.
    Json::Value panoramic;   // will contains the panoramic root value after parsing.
    Json::Reader reader;
    std::ifstream camera_file(camera_filename.c_str(), std::ifstream::binary);
    if(!(camera_file.good() && reader.parse( camera_file, camera, false )))
    {
      std::cerr << "Error reading " << camera_filename <<"\n";
      std::cerr << reader.getFormatedErrorMessages() << "\n";
      return false;
    }
    std::ifstream panoramic_file(panoramic_filename.c_str(), std::ifstream::binary);
    if(!(panoramic_file.good() && reader.parse( panoramic_file, panoramic, false )))
    {
      std::cerr << "Error reading " << panoramic_filename <<"\n";
      std::cerr << reader.getFormatedErrorMessages() << "\n";
      return false;
    }
    double position[3];
    double rotation[9];
    int orientation;
    m_intrinsic = IntrinsicModel::New(camera[camera_id],position,rotation,orientation);
    return m_intrinsic!=NULL && m_extrinsic.Read(panoramic[panoramic_id],position,rotation,orientation);
}
开发者ID:IGNF,项目名称:libOri,代码行数:28,代码来源:Ori.cpp

示例3: setJson

	// SAVE LOAD JSON
	void UserStreamPlayer::setJson( const std::string &aPath ) {
		Json::Value *aJsonValue = new Json::Value();
		Json::Reader reader;

		// Read the filestream
		std::ifstream filestream;

		// Load the file
		std::cout << "UserStreamPlayer::setJson - Attempting to load:" << aPath << std::endl;

		filestream.open( aPath.c_str(), std::ifstream::in);
		if( filestream == 0 ) {
			std::cout << "UserStreamPlayer::setJson - Failed to load file. Ignoring..." << std::endl;
		}

		// Parse the json file or retrieve errors
		bool parsingSuccessful = reader.parse( filestream, *aJsonValue );
		if ( !parsingSuccessful ) {
			// report to the user the failure and their locations in the document.
			std::cout  << "Failed to parse configuration\n" << reader.getFormatedErrorMessages() << std::endl;
			return;
		}

		parseJson ( aJsonValue );
	}
开发者ID:guojenman,项目名称:DisKinect,代码行数:26,代码来源:UserStreamPlayer.cpp

示例4: printf

static int
parseAndSaveValueTree( const std::string &input, 
                       const std::string &actual,
                       const std::string &kind,
                       Json::Value &root )
{
   Json::Reader reader;
   bool parsingSuccessful = reader.parse( input, root );
   if ( !parsingSuccessful )
   {
      printf( "Failed to parse %s file: \n%s\n", 
              kind.c_str(),
              reader.getFormatedErrorMessages().c_str() );
      return 1;
   }

   FILE *factual = fopen( actual.c_str(), "wt" );
   if ( !factual )
   {
      printf( "Failed to create %s actual file.\n", kind.c_str() );
      return 2;
   }
   printValueTree( factual, root );
   fclose( factual );
   return 0;
}
开发者ID:L1quid,项目名称:Slumber,代码行数:26,代码来源:main.cpp

示例5: getExtraLink

std::string API::getExtraLink(const std::string& game_name, const std::string& id)
{
    std::string url, link;
    url = this->config.get_extra_link + game_name + "/" + id + "/";
    std::string json = this->getResponseOAuth(url);

    if (!json.empty())
    {
        Json::Value root;
        Json::Reader *jsonparser = new Json::Reader;
        if (jsonparser->parse(json, root))
        {
            #ifdef DEBUG
                std::cerr << "DEBUG INFO (API::getExtraLink)" << std::endl << root << std::endl;
            #endif
            int available = root["file"]["available"].isInt() ? root["file"]["available"].asInt() : std::stoi(root["file"]["available"].asString());
            if (available)
                link = root["file"]["link"].asString();
        }
        else
        {
            #ifdef DEBUG
                std::cerr << "DEBUG INFO (API::getExtraLink)" << std::endl << json << std::endl;
            #endif
            this->setError(jsonparser->getFormatedErrorMessages());
        }
        delete jsonparser;
    }
    else
    {
        this->setError("Found nothing in " + url);
    }

    return link;
}
开发者ID:rkj,项目名称:lgogdownloader,代码行数:35,代码来源:api.cpp

示例6: TryActivateBlock

bool TMQTTNinjaBridgeHandler::TryActivateBlock()
{

    string url = "http://wakai.ninja.is/rest/v0/block/";
    url += BlockId + "/activate";

	std::ostringstream oss;
    CURLcode rc = GetHttpUrl(url, oss, 10);
	if(rc == CURLE_OK) {
		std::string html = oss.str();
        cerr << "DEBUG: got response: " << html << endl;

        Json::Value root;
        Json::Reader reader;

        if(!reader.parse(html, root, false))  {
            cerr << "ERROR: Failed to parse Ninja activation response" << endl
               << reader.getFormatedErrorMessages() << endl;
            return false;
        }
        if (root.isMember("token")) {
            Token = root["token"].asString();
            cout << "Got token: " << Token << endl;
            return true;
        }

    }

    //~ cerr << "rc: " << rc << endl;
    return false;
}
开发者ID:Perfy,项目名称:wb-homa-drivers,代码行数:31,代码来源:local_connection.cpp

示例7: main

int main(int argc, char *argv[])
{
    // ======= Classi =======
    Simulator simulator; // Simulator
    OgreApp ogreapp(&simulator); // Ogre Application

    // ======= Leggi il file di configurazione =======
    Json::Value conf;
    char config_file_name[512] = "config.conf\0";
    if (argc > 1) {
        snprintf(config_file_name, sizeof(config_file_name), "%s", argv[1]);
    } else {
        usage(argv[0]);
    }
    printf("Leggo il file di configurazione '%s'...\n", config_file_name);
    std::ifstream config_file;
    config_file.open(config_file_name);
    Json::Reader reader;
    if ( !reader.parse( config_file, conf ) ) {
        // report to the user the failure and their locations in the document.
        error("Errore nel leggere il file di configurazione:\n%s", reader.getFormatedErrorMessages().c_str());
    }
    config_file.close();

    // ======= Applica la configurazione =======
    simulator.load_configuration(conf);
    simulator.init_state();
    ogreapp.load_configuration(conf);
    
    // ======= Start =======
    ogreapp.startMainLoop();
    
    return 0;
}
开发者ID:fpoli,项目名称:newton,代码行数:34,代码来源:newton-gui.cpp

示例8: ParseFavoriteInfo

/*
 example for favoorite info
 *** ParseFavoriteInfo {"status":"ok","songs":[
{"song_id":"1770088581", "album_id":"430596","name":"Kiss Kiss Kiss","style":null,"track":"1","artist_name":"\u90d1\u878d","artist_id":"2521",
"lyric":"http:\/\/img.xiami.com\/.\/lyric\/upload\/81\/1770088581_1306767164.lrc",
"inkui_url":"\/2521\/430596\/1770088581.mp3",
"songwriters":null,"composer":null,"threads_count":"0","posts_count":"0",
"listen_file":"\/2521\/430596\/01 1770088581_2098260.mp3","lyric_url":"0",
"has_resource":null,"cd_serial":"1","sub_title":null,"complete":null,"singers":"\u90d1\u878d",
"arrangement":null,"default_resource_id":"2098260","lyric_file":null,"title_url":"Kiss+Kiss+Kiss",
"length":"212","recommends":"221","grade":"3",
"title":"Kiss Kiss Kiss",
"album_logo":"http:\/\/img.xiami.com\/.\/images\/album\/img21\/2521\/4305961300172212_2.jpg",
"location":"http:\/\/f1.xiami.net\/2521\/430596\/01 1770088581_2098260.mp3","low_size":"2545371",
"file_size":"6147852","low_hash":"9ecbd6391d246d68999549b6b4a60b0d","whole_hash":"00c291ff1735682ac3caa5b688f16382",
"content_hash":"00c291ff1735682ac3caa5b688f16382","content_size":"6147852","category":"\u534e\u8bed","lock_lrc":"2","year_play":"45712"},
*/
int DataManager::ParseFavoriteInfo(struct MemoryStruct *pJson)
{
    //printf(" *** ParseFavoriteInfo %s\n", pJson->memory);
    Json::Reader reader;
    Json::Value root;
    bool ret;

    ret = reader.parse((const char*)pJson->memory, root);
    if (!ret)
    {
        // report to the user the failure and their locations in the document.
        std::cout  << "Failed to parse configuration\n"
                   << reader.getFormatedErrorMessages();
        return  0;
    }
    bool isNull = root["status"].isNull();
    if (isNull)
    {
        printf("get songs null\n");
        return 0;
    }
    Json::Value songs;
    ret = false;
    ret=root.isMember("album");
    if(ret) {
        Json::Value album = root["album"];
        songs = album["songs"];
    } else {
        songs = root["songs"];
    }
    retSongNum = songs.size();
    parse_songs(songs, MySongs, XIAMI_MY_SONGS_PAGE);

    return 1;
}
开发者ID:freedombird,项目名称:xm-cli,代码行数:52,代码来源:data_manager.cpp

示例9: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
  const int BufferLength = 1024;
  char readBuffer[BufferLength] = {0,};
  if (false == ReadFromFile("test.json", readBuffer, BufferLength))
    return 0;
  std::string config_doc = readBuffer;
  Json::Value root;
  Json::Reader reader;
  bool parsingSuccessful = reader.parse( config_doc, root );
  if ( !parsingSuccessful )
  {
    std::cout  << "Failed to parse configuration\n"
      << reader.getFormatedErrorMessages();
    return 0;
  }
  std::string encoding = root.get("encoding", "" ).asString();
  std::cout << encoding << std::endl;
  const Json::Value plugins = root["plug-ins"];
  for ( int index = 0; index < plugins.size(); ++index )
  {
    std::cout << plugins[index].asString() << std::endl;
  }
  std::cout << root["indent"].get("length", 0).asInt() << std::endl;
  std::cout << root["indent"]["use_space"].asBool() << std::endl;
  return 0;
}
开发者ID:kyduke,项目名称:study,代码行数:27,代码来源:sample.cpp

示例10: ParseSubBills

int DataManager::ParseSubBills(struct MemoryStruct *pJson)
{
    Json::Reader reader;
    Json::Value root;
    bool ret;
    std::string name;

    //printf(" *** Line :%d ParseSubBills %s\n", __LINE__, pJson->memory);
    ret = reader.parse((const char*)pJson->memory, root);
    if (!ret)
    {
        std::cout  << "Failed to parse configuration\n"<< reader.getFormatedErrorMessages();
        return  false;
    }
    bool isNull = root["status"].isNull();
    if (isNull)
    {
        printf("get bills null\n");
        return false;
    }
    Json::Value songs;
    std::string location;
    songs = root["songs"];
    SongInfo *pSongs = BillSongList[0];
    return parse_songs(songs, pSongs, XIAMI_BILL_SONG_NUM);
}
开发者ID:freedombird,项目名称:xm-cli,代码行数:26,代码来源:data_manager.cpp

示例11: jsonParseFile

Json::Value jsonParseFile(std::string filename)
{
    std::fstream file(filename.c_str(), std::ios::in | std::ios::binary);
    if (!file.is_open())
    {
        std::cout << "Error: could not open file " << filename << "\n";
        return Json::Value();
    }

    file.seekg(0, std::ios::end);
    int length = file.tellg();
    file.seekg(0, std::ios::beg);
    char *buffer = new char[length + 1];
    file.read(buffer, length);

    Json::Reader reader;
    Json::Value root;
    bool parsingSuccessful = reader.parse(buffer, root);
    if (parsingSuccessful)
    {
        return root;
    }
    else
    {
        std::cout << "In file " << filename << ": Parsing error(s):\n" << reader.getFormatedErrorMessages();
        return Json::Value();
    }
}
开发者ID:340211173,项目名称:Ship-Sandbox,代码行数:28,代码来源:util.cpp

示例12: load_card_right_json

int CCardFieldDlg::load_card_right_json()
{
	int i,idx;
	Json::Value root;
	Json::Reader reader;
	std::ifstream input;
	//input.open("e:\\works\\cardlib\\ykt.v3_1.dev\\bin\\lcsmanager\\cardright.json");
	input.open((LPCTSTR)m_jsonfile);
	if(input.is_open()==false)
	{
		AfxMessageBox("´ò¿ªÅäÖÃÎļþ´íÎó");
		return -1;
	}
	if(reader.parse(input,root)==false)
	{
		std::string msg = "¶ÁÈ¡ÅäÖÃÎļþ´íÎó : " + reader.getFormatedErrorMessages();
		AfxMessageBox(msg.c_str());
		return -1;
	}
	std::string encoding = root.get("encoding","GBK").asString();
	Json::Value fields = root["cardfield"];
	Json::Value::Members fldid = fields.getMemberNames();
	m_cardfield.clear();
	for(i = 0;i < fldid.size();++i)
	{
		idx = atoi(fldid[i].c_str());
		std::string v = fields.get(fldid[i],"Unknown").asString();
		m_cardfield.insert(CARD_FILED_MAP::value_type(idx,v));
	}
	if(fldid.size() > m_string_len)
		m_string_len = fldid.size();
//	std::sort(m_cardfield.begin(),m_cardfield.end());
	init_check_box();
	return 0;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:35,代码来源:CardFieldDlg.cpp

示例13: jsonParse

void jsonParse() {
    ifstream jsonFile;
    jsonFile.open("/private/tmp/Ekho/search.json");
    stringstream strStream;
    strStream << jsonFile.rdbuf();
    string jsonString = strStream.str();

    Json::Value root;
    Json::Reader reader;
    bool parseSuccess = reader.parse(jsonString, root, false);

    if (!parseSuccess) {
        printf("Failed to parse JSON file.\n");
        cout << reader.getFormatedErrorMessages() << endl;
        return;
    }
    const Json::Value array = root["url"];
    for (unsigned int index=0; index < array.size(); ++index) {
        cout << "Element " << index << " in array: " << array[index].asString() << endl;
    }

    const Json::Value notAnArray = root["not an array"];
    if (!notAnArray.isNull()) {
        cout << "Not an array: " << notAnArray.asString() << endl;
    }

    cout << "Json pretty print: " << endl << root.toStyledString() << endl;

    return;
}
开发者ID:EkhoTeam,项目名称:Ekho,代码行数:30,代码来源:jsonparse.cpp

示例14: jsonParse

int jsonParse(string _s)
{
    // Let's parse it
    Json::Value root;
    Json::Reader reader;
    bool parsedSuccess = reader.parse(_s,
                                      root,
                                      false);

    if (not parsedSuccess) {
        // Report failures and their locations
        // in the document.
        cout << "Failed to parse JSON" << endl
             << reader.getFormatedErrorMessages()
             << endl;
        return 1;
    }

    Json::Value::Members mem = root.getMemberNames();
    Json::Value child = root[mem[0]];
    cout << "name: " << mem[0] << ", child: " << child.asString() << endl;
    for (int i = 1; i < mem.size(); ++i)
    {
        child = root[mem[i]];
        cout << "name: " << mem[i] << endl;
        Json::Value::Members childMem = child.getMemberNames();
        cout << "\t" << "type: " << child[childMem[0]].asString() << endl;
        cout << "\t" << "value: " << child[childMem[1]].asString() << endl;
        cout << "\t" << "typeGen: " << child[childMem[2]].asString() << endl;
    }
    return 1;
}
开发者ID:skyline-gleb,项目名称:fuzzy-tyrion,代码行数:32,代码来源:jsonparse.cpp

示例15: readEditList

void WriterConfig::readEditList(const std::string& filename, IsoMediaFile::Thumbs& thumbs) const
{
    Json::Reader jsonReader;
    std::ifstream editListFile(filename);
    if (!editListFile.is_open())
    {
        throw std::runtime_error("Unable to open input file '" + filename + "'");
    }

    // Parse the editlist file
    Json::Value edit;
    bool parsingSuccess = jsonReader.parse(editListFile, edit, false);
    if (not parsingSuccess)
    {
        throw std::runtime_error("Failed to parse edit list file: " + jsonReader.getFormatedErrorMessages());
    }

    thumbs.edit_list.numb_rept = std::stoi(edit["numb_rept"].asString());
    for (unsigned int editIndex = 0; editIndex < edit["edit_unit"].size(); ++editIndex)
    {
        IsoMediaFile::EditUnit newEditUnit;

        newEditUnit.edit_type = edit["edit_unit"][editIndex]["edit_type"].asString();
        newEditUnit.mdia_time = std::stoi(edit["edit_unit"][editIndex]["mdia_time"].asString());
        newEditUnit.time_span = std::stoi(edit["edit_unit"][editIndex]["time_span"].asString());

        thumbs.edit_list.edit_unit.push_back(newEditUnit);
    }
}
开发者ID:pstanczyk,项目名称:heif,代码行数:29,代码来源:writercfg.cpp


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