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

C++ json::Value类代码示例

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

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



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

示例1: addOption

/// Adds the default connector options. Also updates the capabilities structure with the default options.
/// Besides the options addBasicConnectorOptions adds, this function also adds port and interface options.
void Util::Config::addConnectorOptions(int port, JSON::Value & capabilities){
  JSON::Value option;
  option.null();
  option["long"] = "port";
  option["short"] = "p";
  option["arg"] = "integer";
  option["help"] = "TCP port to listen on";
  option["value"].append((long long)port);
  addOption("listen_port", option);
  capabilities["optional"]["port"]["name"] = "TCP port";
  capabilities["optional"]["port"]["help"] = "TCP port to listen on - default if unprovided is "+option["value"][0u].asString();
  capabilities["optional"]["port"]["type"] = "uint";
  capabilities["optional"]["port"]["option"] = "--port";
  capabilities["optional"]["port"]["default"] = option["value"][0u];
  
  option.null();
  option["long"] = "interface";
  option["short"] = "i";
  option["arg"] = "string";
  option["help"] = "Interface address to listen on, or 0.0.0.0 for all available interfaces.";
  option["value"].append("0.0.0.0");
  addOption("listen_interface", option);
  capabilities["optional"]["interface"]["name"] = "Interface";
  capabilities["optional"]["interface"]["help"] = "Address of the interface to listen on - default if unprovided is all interfaces";
  capabilities["optional"]["interface"]["option"] = "--interface";
  capabilities["optional"]["interface"]["type"] = "str";
  
  addBasicConnectorOptions(capabilities);
} //addConnectorOptions
开发者ID:valurhrafn,项目名称:mistlib,代码行数:31,代码来源:config.cpp


示例2: getNext

 void inputFLV::getNext(bool smart) {
   static JSON::Value thisPack;
   static AMF::Object amf_storage;
   thisPack.null();
   long long int lastBytePos = ftell(inFile);
   FLV::Tag tmpTag;
   while (!feof(inFile) && !FLV::Parse_Error){
     if (tmpTag.FileLoader(inFile)){
       thisPack = tmpTag.toJSON(myMeta, amf_storage);
       thisPack["bpos"] = lastBytePos;
       if ( !selectedTracks.count(thisPack["trackid"].asInt())){
         getNext();
       }
       break;
     }
   }
   if (FLV::Parse_Error){
     FAIL_MSG("FLV error: %s", FLV::Error_Str.c_str());
     thisPack.null();
     thisPacket.null();
     return;
   }
   std::string tmpStr = thisPack.toNetPacked();
   thisPacket.reInit(tmpStr.data(), tmpStr.size());
 }
开发者ID:TribeMedia,项目名称:mistserver,代码行数:25,代码来源:input_flv.cpp


示例3: readHeader

 bool inputFLV::readHeader() {
   JSON::Value lastPack;
   if (!inFile) {
     return false;
   }
   //See whether a separate header file exists.
   DTSC::File tmp(config->getString("input") + ".dtsh");
   if (tmp){
     myMeta = tmp.getMeta();
     return true;
   }
   //Create header file from FLV data
   fseek(inFile, 13, SEEK_SET);
   FLV::Tag tmpTag;
   long long int lastBytePos = 13;
   while (!feof(inFile) && !FLV::Parse_Error){
     if (tmpTag.FileLoader(inFile)){
       lastPack.null();
       lastPack = tmpTag.toJSON(myMeta);
       lastPack["bpos"] = lastBytePos;
       myMeta.update(lastPack);
       lastBytePos = ftell(inFile);
     }
   }
   if (FLV::Parse_Error){
     std::cerr << FLV::Error_Str << std::endl;
     return false;
   }
   std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
   oFile << myMeta.toJSON().toNetPacked();
   oFile.close();
   return true;
 }
开发者ID:keyanmca,项目名称:mistserver,代码行数:33,代码来源:input_flv.cpp


示例4: ParseStageConnections

void CompositorLoader::ParseStageConnections(CompositeStageConnections& connections, const json::Value& stageJson)
{
	if (stageJson.HasKey("input") && stageJson["input"].GetType() == ArrayVal)
	{
		Array inputArray = stageJson["input"].ToArray();

		for (auto it = inputArray.begin(); it != inputArray.end(); ++it)
		{
			connections.AddRenderTargetInput(it->ToString(""));
		}
	}
	
	if (stageJson.HasKey("output") && stageJson["output"].GetType() == ArrayVal)
	{
		Array inputArray = stageJson["output"].ToArray();

		for (auto it = inputArray.begin(); it != inputArray.end(); ++it)
		{
			connections.AddRenderTarget(it->ToString(""));
		}
	}
	
	if (stageJson.HasKey("depthBuffer") && stageJson["depthBuffer"].GetType() == StringVal)
	{
		connections.SetDepthBuffer(stageJson["depthBuffer"].ToString());
	}
}
开发者ID:lambertjamesd,项目名称:Krono,代码行数:27,代码来源:CompositorLoader.cpp


示例5: CompareJson

void CompareJson(json::Value& lhs, json::Value& rhs, json::Value& output) {
  std::string lstr, rstr;
  if (rhs.type() != lhs.type()) return;
  switch (lhs.type()) {
  case json::Value::tString:
    lstr = lhs.getString();
    rstr = rhs.getString();
    if (!lstr.empty() && lstr[0] == '$' && lstr.back() == '$') {
      size_t slash = lstr.find('/');
      std::string cat = lstr.substr(1, slash - 1);
      std::string name = lstr.substr(slash + 1, lstr.length() - slash - 2);
      output[cat][name] = rstr;
    }
    break;
  case json::Value::tArray:
    for (size_t i = 0; i < lhs.length(); ++i) {
      if (i < rhs.length()) {
        CompareJson(lhs[i], rhs[i], output);
      }
    }
    break;
  case json::Value::tObject:
    for (auto it = lhs.begin(); it != lhs.end(); ++it) {
      if (rhs.has(it.key())) {
        CompareJson(*it, rhs[it.key()], output);
      }
    }
    break;
  }
}
开发者ID:d07RiV,项目名称:SNOParser,代码行数:30,代码来源:locale.cpp


示例6: parsePrefab

void Animation::parsePrefab(json::Value& val)
{
	if(val.isMember("sequences") && !val["sequences"].empty())
	{
		json::Value sequences = val["sequences"];

		for(json::Value::iterator it = sequences.begin(); it != sequences.end(); ++it)
		{
			if(!(*it).isMember("start") || !(*it).isMember("end") || !(*it).isMember("fps"))
			{
				szerr << "Animation sequence definition must have start and end frame and fps value." << ErrorStream::error;
				continue;
			}

			sf::Uint32 start	= (*it)["start"].asUInt();
			sf::Uint32 end		= (*it)["end"].asUInt();
			sf::Uint32 fps		= (*it)["fps"].asUInt();

			bool looping		= (*it).get("looping", 0).asBool();
			std::string next	= (*it).get("next", "").asString();

			defineAnimation(it.memberName(), start, end, fps, looping, next);
		}
	}

	if(val.isMember("autoplay"))
	{
		if(val["autoplay"].isString())
		{
			play(val["autoplay"].asString());
		}
	}
}
开发者ID:Sonaza,项目名称:scyori,代码行数:33,代码来源:Animation.cpp


示例7: couchLoadData

static void couchLoadData(PrintTextA &print) {
	CouchDB db(getTestCouch());
	db.use(DATABASENAME);


	AutoArray<Document, SmallAlloc<50> > savedDocs;

	Changeset chset(db.createChangeset());
	natural id=10000;
	JSON::Value data = db.json.factory->fromString(strdata);
	for (JSON::Iterator iter = data->getFwIter(); iter.hasItems();) {
		const JSON::KeyValue &kv= iter.getNext();
		Document doc;
		doc.edit(db.json)
				("name",kv[0])
				("age",kv[1])
				("height",kv[2])
				("_id",ToString<natural>(id,16));
		id+=14823;
		savedDocs.add(doc);
		chset.update(doc);
	}
	chset.commit(false);
	Set<StringA> uuidmap;

	for (natural i = 0; i < savedDocs.length(); i++) {
		StringA uuid = savedDocs[i]["_id"]->getStringUtf8();
//		print("%1\n") << uuid;
		uuidmap.insert(uuid);
	}
	print("%1") << uuidmap.size();

}
开发者ID:ondra-novak,项目名称:lightcouch,代码行数:33,代码来源:test_basics.cpp


示例8: ParseStage

void CompositorLoader::ParseStage(ResourceManager& resourceManager, Compositor::Ptr& compositor, const json::Value& stageJson)
{
	if (stageJson.HasKey("disabled") && stageJson["disabled"].ToBool(false))
	{
		return;
	}

	if (!stageJson.HasKey("stage") || stageJson["stage"].GetType() != StringVal)
	{
		throw FormatException("stages[].stage needs to be a string containing the relvative path to a CompositeStage");
	}

	CompositeStageConnections connections;

	ParseStageConnections(connections, stageJson);

	std::string stageFilename = stageJson["stage"].ToString();
	CompositeStage::Ptr stage = resourceManager.LoadResource<CompositeStage>(stageFilename);

	if (stageJson.HasKey("shaderValues"))
	{
		Array defaultValues = stageJson["shaderValues"].ToArray();

		for (auto it = defaultValues.begin(); it != defaultValues.end(); ++it)
		{
			JsonTypeHelper::ParseValueIntoParameters(stage->GetStateParameters(), *it);
		}
	}

	compositor->AddCompositeStage(stage, connections);
}
开发者ID:lambertjamesd,项目名称:Krono,代码行数:31,代码来源:CompositorLoader.cpp


示例9: CheckAllStreams

 void CheckAllStreams(JSON::Value & data){
   long long int currTime = Util::epoch();
   for (JSON::ObjIter jit = data.ObjBegin(); jit != data.ObjEnd(); jit++){
     if ( !Util::Procs::isActive(jit->first)){
       startStream(jit->first, jit->second);
     }
     if (currTime - lastBuffer[jit->first] > 5){
       if (jit->second.isMember("error") && jit->second["error"].asString() != ""){
         jit->second["online"] = jit->second["error"];
       }else{
         jit->second["online"] = 0;
       }
     }else{
       jit->second["online"] = 1;
     }
   }
   static JSON::Value strlist;
   bool changed = false;
   if (strlist["config"] != Storage["config"]){
     strlist["config"] = Storage["config"];
     changed = true;
   }
   if (strlist["streams"] != Storage["streams"]){
     strlist["streams"] = Storage["streams"];
     changed = true;
   }
   if (changed){
     WriteFile("/tmp/mist/streamlist", strlist.toString());
   }
 }
开发者ID:hb-loken,项目名称:mistserver,代码行数:30,代码来源:controller_streams.cpp


示例10: numberToWide

	static void numberToWide(PrintTextA &print) {
		JSON::PFactory f = JSON::create();
		JSON::Value v = f->newValue((natural)123);
		String tst1 = v->getString();
		String tst2 = v->getString();
		print("%1,%2") << tst1 << tst2;
	}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:7,代码来源:test_json.cpp


示例11: dynamicBootstrap

  ///\brief Builds a bootstrap for use in HTTP Dynamic streaming.
  ///\param streamName The name of the stream.
  ///\param metadata The current metadata, used to generate the index.
  ///\param fragnum The index of the current fragment
  ///\return The generated bootstrap.
  std::string dynamicBootstrap(std::string & streamName, JSON::Value & metadata, int fragnum = 0){
    std::string empty;

    MP4::ASRT asrt;
    asrt.setUpdate(false);
    asrt.setVersion(1);
    //asrt.setQualityEntry(empty, 0);
    if (metadata.isMember("live")){
      asrt.setSegmentRun(1, 4294967295ul, 0);
    }else{
      asrt.setSegmentRun(1, metadata["keytime"].size(), 0);
    }

    MP4::AFRT afrt;
    afrt.setUpdate(false);
    afrt.setVersion(1);
    afrt.setTimeScale(1000);
    //afrt.setQualityEntry(empty, 0);
    MP4::afrt_runtable afrtrun;
    if (metadata.isMember("live")){
      // restrict data to last 2 fragments, unless an earlier fragment was expressly requested.
      int count = 0;
      unsigned int begin = std::max(0u, metadata["keynum"].size() - 3);
      while (begin > 0 && fragnum && metadata["keynum"][begin].asInt() > fragnum){
        begin--;
      }
      for (int i = begin; i < metadata["keynum"].size(); i++){
        afrtrun.firstFragment = metadata["keynum"][i].asInt();
        afrtrun.firstTimestamp = metadata["keytime"][i].asInt();
        afrtrun.duration = metadata["keylen"][i].asInt();
        afrt.setFragmentRun(afrtrun, count++);
      }
    }else{
      for (int i = 0; i < metadata["keynum"].size(); i++){
        afrtrun.firstFragment = metadata["keynum"][i].asInt();
        afrtrun.firstTimestamp = metadata["keytime"][i].asInt();
        afrtrun.duration = metadata["keylen"][i].asInt();
        afrt.setFragmentRun(afrtrun, i);
      }
    }

    MP4::ABST abst;
    abst.setVersion(1);
    abst.setBootstrapinfoVersion(1);
    abst.setProfile(0);
    abst.setUpdate(false);
    abst.setTimeScale(1000);
    abst.setLive(false);
    abst.setCurrentMediaTime(metadata["lastms"].asInt());
    abst.setSmpteTimeCodeOffset(0);
    abst.setMovieIdentifier(streamName);
    abst.setSegmentRunTable(asrt, 0);
    abst.setFragmentRunTable(afrt, 0);

#if DEBUG >= 8
    std::cout << "Sending bootstrap:" << std::endl << abst.toPrettyString(0) << std::endl;
#endif
    return std::string((char*)abst.asBox(), (int)abst.boxedSize());
  }
开发者ID:CloudMetal,项目名称:mistserver,代码行数:64,代码来源:conn_http_dynamic.cpp


示例12: BuildManifest

  /// Returns a Smooth-format manifest file
  std::string BuildManifest(std::string & MovieId, JSON::Value & metadata){
    std::stringstream Result;
    Result << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    Result << "<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" TimeScale=\"10000000\" Duration=\"" << metadata["lastms"].asInt()
        << "\">\n";
    if (metadata.isMember("audio")){
      Result << "  <StreamIndex Type=\"audio\" QualityLevels=\"1\" Name=\"audio\" Chunks=\"" << metadata["keytime"].size()
          << "\" Url=\"Q({bitrate})/A({start time})\">\n";
      Result << "    <QualityLevel Index=\"0\" Bitrate=\"" << metadata["audio"]["bps"].asInt() * 8 << "\" CodecPrivateData=\"";
      Result << std::hex;
      for (int i = 0; i < metadata["audio"]["init"].asString().size(); i++){
        Result << std::setfill('0') << std::setw(2) << std::right << (int)metadata["audio"]["init"].asString()[i];
      }
      Result << std::dec;
      Result << "\" SamplingRate=\"" << metadata["audio"]["rate"].asInt()
          << "\" Channels=\"2\" BitsPerSample=\"16\" PacketSize=\"4\" AudioTag=\"255\" FourCC=\"AACL\"  />\n";
      for (int i = 0; i < metadata["keytime"].size() - 1; i++){
        Result << "    <c ";
        if (i == 0){
          Result << "t=\"0\" ";
        }
        Result << "d=\"" << 10000 * (metadata["keytime"][i + 1].asInt() - metadata["keytime"][i].asInt()) << "\" />\n";
      }
      Result << "    <c d=\"" << 10000 * (metadata["lastms"].asInt() - metadata["keytime"][metadata["keytime"].size() - 1].asInt()) << "\" />\n";
      Result << "   </StreamIndex>\n";
    }
    if (metadata.isMember("video")){
      Result << "  <StreamIndex Type=\"video\" QualityLevels=\"1\" Name=\"video\" Chunks=\"" << metadata["keytime"].size()
          << "\" Url=\"Q({bitrate})/V({start time})\" MaxWidth=\"" << metadata["video"]["width"].asInt() << "\" MaxHeight=\""
          << metadata["video"]["height"].asInt() << "\" DisplayWidth=\"" << metadata["video"]["width"].asInt() << "\" DisplayHeight=\""
          << metadata["video"]["height"].asInt() << "\">\n";
      Result << "    <QualityLevel Index=\"0\" Bitrate=\"" << metadata["video"]["bps"].asInt() * 8 << "\" CodecPrivateData=\"";
      MP4::AVCC avccbox;
      avccbox.setPayload(metadata["video"]["init"].asString());
      std::string tmpString = avccbox.asAnnexB();
      Result << std::hex;
      for (int i = 0; i < tmpString.size(); i++){
        Result << std::setfill('0') << std::setw(2) << std::right << (int)tmpString[i];
      }
      Result << std::dec;
      Result << "\" MaxWidth=\"" << metadata["video"]["width"].asInt() << "\" MaxHeight=\"" << metadata["video"]["height"].asInt()
          << "\" FourCC=\"AVC1\" />\n";
      for (int i = 0; i < metadata["keytime"].size() - 1; i++){
        Result << "    <c ";
        if (i == 0){
          Result << "t=\"0\" ";
        }
        Result << "d=\"" << 10000 * (metadata["keytime"][i + 1].asInt() - metadata["keytime"][i].asInt()) << "\" />\n";
      }
      Result << "    <c d=\"" << 10000 * (metadata["lastms"].asInt() - metadata["keytime"][metadata["keytime"].size() - 1].asInt()) << "\" />\n";
      Result << "   </StreamIndex>\n";
    }
    Result << "</SmoothStreamingMedia>\n";

#if DEBUG >= 8
    std::cerr << "Sending this manifest:" << std::endl << Result << std::endl;
#endif
    return Result.str();
  } //BuildManifest
开发者ID:hb-loken,项目名称:mistserver,代码行数:60,代码来源:conn_http_smooth.cpp


示例13: serializeCycleError

	static void serializeCycleError(PrintTextA &print) {
		JSON::PFactory f = JSON::create();
		JSON::Value v = f->fromString(jsonSrc);
		JSON::Value arr = v["array"];
		arr->add(v);
		v->erase("text");
		JSON::serialize(v, print.nxChain(), false);
		v->erase("array");
	}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:9,代码来源:test_json.cpp


示例14: resetStream

/// Adds a single DTSC packet to the stream, updating the internal metadata if needed.
void DTSC::Stream::addPacket(JSON::Value & newPack) {
  livePos newPos;
  newPos.trackID = newPack["trackid"].asInt();
  newPos.seekTime = newPack["time"].asInt();
  if (!metadata.tracks.count(newPos.trackID) && (!newPack.isMember("mark") || newPack["mark"].asStringRef() != "pause")) {
    return;
  }
  if (buffercount > 1 && metadata.tracks[newPos.trackID].keys.size() > 1 && newPos.seekTime < (long long unsigned int)metadata.tracks[newPos.trackID].keys.rbegin()->getTime()) {
    resetStream();
  }
  while (buffers.count(newPos) > 0) {
    newPos.seekTime++;
  }
  while (buffercount == 1 && buffers.size() > 0) {
    cutOneBuffer();
  }
  buffers[newPos] = newPack;
  datapointertype = INVALID;
  std::string tmp = "";
  if (newPack.isMember("trackid") && newPack["trackid"].asInt() > 0) {
    tmp = metadata.tracks[newPack["trackid"].asInt()].type;
  }
  if (newPack.isMember("datatype")) {
    tmp = newPack["datatype"].asStringRef();
  }
  if (tmp == "video") {
    datapointertype = VIDEO;
  }
  if (tmp == "audio") {
    datapointertype = AUDIO;
  }
  if (tmp == "meta") {
    datapointertype = META;
  }
  if (tmp == "pause_marker" || (newPack.isMember("mark") && newPack["mark"].asStringRef() == "pause")) {
    datapointertype = PAUSEMARK;
  }
  if (buffercount > 1) {
    metadata.update(newPack);
    if (newPack.isMember("keyframe") || (long long unsigned int)metadata.tracks[newPos.trackID].keys.rbegin()->getTime() == newPos.seekTime) {
      keyframes[newPos.trackID].insert(newPos);
    }
    metadata.live = true;
    //throw away buffers if buffer time is met
    int trid = buffers.begin()->first.trackID;
    int firstTime = buffers.begin()->first.seekTime;
    int lastTime = buffers.rbegin()->first.seekTime - buffertime;
    while ((!metadata.tracks[trid].keys.size() && firstTime < lastTime) || (metadata.tracks[trid].keys.size() && metadata.tracks[trid].keys.rbegin()->getTime() < lastTime) || (metadata.tracks[trid].keys.size() > 2 && metadata.tracks[trid].keys.rbegin()->getTime() - firstTime > buffertime)) {
      cutOneBuffer();
      trid = buffers.begin()->first.trackID;
      firstTime = buffers.begin()->first.seekTime;
    }
    metadata.bufferWindow = buffertime;
  }

}
开发者ID:FihlaTV,项目名称:mistserver,代码行数:57,代码来源:dtsc.cpp


示例15: is_valid

bool AddressValidator::is_valid(const json::Value& value) {
    if (!value.is_string()) {
        return false;
    }
    const auto& val = value.as_string();
    if ("localhost" == val) {
        return true;
    }
    return std::regex_match(val, m_address_regex);
}
开发者ID:iamyaw,项目名称:IntelRackScaleArchitecture,代码行数:10,代码来源:address.cpp


示例16: CheckAllStreams

///\brief Checks all streams, restoring if needed.
///\param data The stream configuration for the server.
void CheckAllStreams(JSON::Value & data) {
    long long int currTime = Util::epoch();
    for (JSON::ObjIter jit = data.ObjBegin(); jit != data.ObjEnd(); jit++) {
        if ( !Util::Procs::isActive(jit->first)) {
            startStream(jit->first, jit->second);
        }
        if (currTime - lastBuffer[jit->first] > 5) {
            if (jit->second.isMember("source") && jit->second["source"].asString().substr(0, 1) == "/" && jit->second.isMember("error")
                    && jit->second["error"].asString() == "Available") {
                jit->second["online"] = 2;
            } else {
                if (jit->second.isMember("error") && jit->second["error"].asString() == "Available") {
                    jit->second.removeMember("error");
                }
                jit->second["online"] = 0;
            }
        } else {
            // assume all is fine
            jit->second.removeMember("error");
            jit->second["online"] = 1;
            // check if source is valid
            if (jit->second.isMember("live") && !jit->second.isMember("meta") || !jit->second["meta"]) {
                jit->second["online"] = 0;
                jit->second["error"] = "No (valid) source connected";
            } else {
                // for live streams, keep track of activity
                if (jit->second["meta"].isMember("live")) {
                    if (jit->second["meta"]["lastms"] != jit->second["lastms"]) {
                        jit->second["lastms"] = jit->second["meta"]["lastms"];
                        jit->second["last_active"] = currTime;
                    }
                    // mark stream as offline if no activity for 5 seconds
                    if (jit->second.isMember("last_active") && jit->second["last_active"].asInt() < currTime - 5) {
                        jit->second["online"] = 0;
                        jit->second["error"] = "No (valid) source connected";
                    }
                }
            }
        }
    }
    static JSON::Value strlist;
    bool changed = false;
    if (strlist["config"] != Storage["config"]) {
        strlist["config"] = Storage["config"];
        changed = true;
    }
    if (strlist["streams"] != Storage["streams"]) {
        strlist["streams"] = Storage["streams"];
        changed = true;
    }
    if (changed) {
        WriteFile("/tmp/mist/streamlist", strlist.toString());
    }
}
开发者ID:FihlaTV,项目名称:mistserver-1,代码行数:56,代码来源:controller_streams.cpp


示例17: valueToString

void JsonStream::valueToString(json::Value &value, std::string& str)
{
    if(value.GetType() == json::StringVal)
    {
        str = value.ToString();
    }
    else
    {
        mIsOk = false;
        mErrorLog += "JsonStream::valueToString() Error: wrong type\n";
    }
}
开发者ID:Naeren,项目名称:RetroShare,代码行数:12,代码来源:JsonStream.cpp


示例18: ListStrings

void ListStrings(json::Value& value, json::Value& data) {
  for (auto& kv : value.getMap()) {
    if (kv.second.type() == json::Value::tObject) {
      for (auto& skv : kv.second.getMap()) {
        data["stringlist"][kv.first][skv.first]["text"] = skv.first;
      }
    } else {
      data["stringlist"]["Global"][kv.first]["text"] = kv.first;
    }
  }
  value.clear();
}
开发者ID:d07RiV,项目名称:SNOParser,代码行数:12,代码来源:locale.cpp


示例19: processMessage

void ClientWS::processMessage(JSON::Value v) {
	try {
		JSON::Value result = v["result"];
		JSON::Value error = v["error"];
		JSON::Value context = v["context"];
		JSON::Value method = v["method"];
		JSON::Value id = v["id"];
		JSON::Value params = v["params"];
		if (result != null || error != null) {
			if (id != null && !id->isNull()) {

				natural reqid = id->getUInt();
				const Promise<Result> *p = waitingResults.find(reqid);
				if (p == 0)
					onDispatchError(v);
				else {
					Promise<Result> q = *p;
					waitingResults.erase(reqid);
					if (p) {
						if (error == null || error->isNull()) {
							q.resolve(Result(result,context));
						} else {
							q.reject(RpcError(THISLOCATION,error));
						}
					}
				}
			}//id=null - invalid frame
			else {
				onDispatchError(v);
			}
		} else if (method != null && params != null) {
			if (id == null || id->isNull()) {
				onNotify(method->getStringUtf8(), params, context);
			} else {
				try {
					onIncomeRPC(method->getStringUtf8(), params,context,id);
				} catch (const RpcError &e) {
					sendResponse(id, jsonFactory->newValue(null), e.getError());
				} catch (const jsonsrv::RpcCallError &c) {
					RpcError e(THISLOCATION,jsonFactory,c.getStatus(),c.getStatusMessage());
					sendResponse(id, jsonFactory->newValue(null), e.getError());
				} catch (const std::exception &s) {
					RpcError e(THISLOCATION,jsonFactory,500,s.what());
					sendResponse(id, jsonFactory->newValue(null), e.getError());
				} catch (...) {
					RpcError e(THISLOCATION,jsonFactory,500,"fatal");
					sendResponse(id, jsonFactory->newValue(null), e.getError());
				}

			}
		}

	} catch (...) {
		onDispatchError(v);
	}

}
开发者ID:ondra-novak,项目名称:jsonrpcserver,代码行数:57,代码来源:clientWS.cpp


示例20: build_json_map

    void build_json_map(const json::Value& json) {
        for (auto it = json.cbegin(); it != json.cend(); ++it) {
            m_json_path.push_key(it.key());
            const auto& json_value = *it;

            m_json_map[m_json_path.get_path()] = json_value;

            if (!json_value.is_array()) {
                build_json_map(json_value);
            }
            m_json_path.pop_key();
        }
    }
开发者ID:iamyaw,项目名称:intelRSD,代码行数:13,代码来源:schema_validator.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ json::ValueIterator类代码示例发布时间:2022-05-31
下一篇:
C++ json::StyledWriter类代码示例发布时间: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