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


C++ value::is_null方法代码示例

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


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

示例1: print_json

void print_json(const json::value & jvalue)
{
   if (!jvalue.is_null())
   {
        cout << jvalue << endl;
   }
}
开发者ID:Benguang,项目名称:DistributedR,代码行数:7,代码来源:exampleclient1.cpp

示例2: ReportTaskCompletion

void RemoteExecutor::ReportTaskCompletion(
    int jobId, int taskId, int taskRequeueCount, json::value jsonBody,
    const std::string& callbackUri)
{
    try
    {
        if (!jsonBody.is_null())
        {
            Logger::Debug(jobId, taskId, taskRequeueCount,
                "Callback to {0} with {1}", callbackUri, jsonBody);

            client::http_client client = HttpHelper::GetHttpClient(callbackUri);
            http_request request = HttpHelper::GetHttpRequest(methods::POST, jsonBody);
            http_response response = client.request(request).get();

            Logger::Info(jobId, taskId, taskRequeueCount,
                "Callback to {0} response code {1}", callbackUri, response.status_code());
        }
    }
    catch (const std::exception& ex)
    {
        this->jobTaskTable.RequestResync();
        Logger::Error(jobId, taskId, taskRequeueCount,
            "Exception when sending back task result. {0}", ex.what());
    }
}
开发者ID:sunbinzhu,项目名称:whpc-linux-communicator,代码行数:26,代码来源:RemoteExecutor.cpp

示例3: __print_scalar

static void __print_scalar (string & result, const json::value & v)
{
    if (v.is_null()) {
        result.append("null");
    } else if (v.is_string()) {
		string r;
		result.append(1, '"');
		result.append(v.get<string>());
		result.append(1, '"');
	} else {
    	result.append(v.get<string>());
    }
}
开发者ID:semenovf,项目名称:pfs-json,代码行数:13,代码来源:pretty_print.cpp

示例4: flattenJsonInnerLoop

void GoogleSearchClient::flattenJsonInnerLoop(json::value const & val, FlatJsonObject & json_map) {
  // input : Body of the google search response as json::value
  // This recursive function parse the Json raw value to a C++ multimap
  if (!val.is_null() && val.is_object()) {
    for (auto const &iter : val.as_object()) {
      //iter on each element for Json object type. Return a vect<string_t,json::value>
      const auto &mapKey = iter.first;
      const auto &content = iter.second;
      json_map.insert(std::pair<utility::string_t, utility::string_t>(mapKey, content.serialize()));
      flattenJsonInnerLoop(content, json_map);
    }
  } else if (val.is_array()) {
    for (auto const &content : val.as_array()) {
      //iter on each element for Json array type. Return a json::value
      flattenJsonInnerLoop(content, json_map);
    }
  }
}
开发者ID:pdib,项目名称:ppt-forgery,代码行数:18,代码来源:GoogleSearchClient.cpp

示例5: _build_request

http::http_request http_client_impl::_build_request(http::method method, http::uri_builder request_uri, const ::utility::string_t& accept, json::value object) const
{
    http::http_request msg(method);

    if (!accept.empty())
        msg.headers().add(U("Accept"), accept);

    msg.set_request_uri(request_uri.to_uri());

    if (method == http::methods::POST || method == http::methods::PUT || method == http::methods::PATCH)
    {
        if(object.is_null() || !object.is_object())
            throw std::invalid_argument("POST, PUT, and PATCH requests require a payload");

        msg.set_body(object);
    }

    return msg;
}
开发者ID:zjufish,项目名称:odatacpp,代码行数:19,代码来源:http_implement.cpp

示例6: print_search_results

void print_search_results(json::value const & value)
{
	if (!value.is_null())
	{
		//auto response = value.at(L"data");
		//auto results = response[L"movies"];

		// iteration is supported not directly on json::value but on 
		// json::object and json::array. Use json::value::as_object() and json::value::as_array().
		std::wcout << value.as_array().at(0) << std::endl;
		for (auto const & o : value.as_array())
		{
			auto id = o.at(L"id");
			auto name = o.at(L"name");
			auto username = o.at(L"username");
			auto email = o.at(L"email");
			auto address = o.at(L"address");
			auto street = address.at(L"street");
			
			std::wcout << id << std::endl << name << std::endl << username << std::endl << email << std::endl << street << std::endl << std::endl;
		}
	}
}
开发者ID:ourselin,项目名称:Master,代码行数:23,代码来源:Source.cpp

示例7: ParserResponse

void Leanplum::ParserResponse(json::value response)
{
	if (response.is_null()){
		return;
	}

	CString key;
	VARIABLE_TYPE type;
	typedef std::map<CString, std::pair<VARIABLE_TYPE, CString>>::iterator it_type;
	for(it_type iterator = m_variablesMap.begin(); iterator != m_variablesMap.end(); iterator++) {
		key = iterator->first;
		type = iterator->second.first;
		if (VARIABLE_TYPE::INT == type) {
			 int v = response.at(key.GetBuffer()).as_integer();
			 iterator->second.second.Format(_T("%d"), v);
		} else if (VARIABLE_TYPE::BOOL == type) {
			bool v = response.at(key.GetBuffer()).as_bool();
			iterator->second.second = v? _T("true"):_T("false");
		} else if (VARIABLE_TYPE::STRING == type) {
			iterator->second.second = response.at(key.GetBuffer()).as_string().c_str();
		}
	}
}
开发者ID:FreyaTsao,项目名称:windows_leanplum_sdk,代码行数:23,代码来源:Leanplum.cpp

示例8: REQUIRE

// ----------------------------------------------------------------------------
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
// ----------------------------------------------------------------------------
#include <json/json.h>

// ----------------------------------------------------------------------------
TEST_CASE( "default-constructed-value-is-null", "[value]" )
{
  json::value v;

  REQUIRE( v.is_null() == true );
}

// ----------------------------------------------------------------------------
TEST_CASE( "construct-number", "[value]" )
{
  json::value v1{1.234};
  json::value v2 = 10;

  REQUIRE( v1.as_number() == 1.234 );
  REQUIRE( v2.as_number() == 10 );
}

// ----------------------------------------------------------------------------
TEST_CASE( "construct-object-by-initializer-list", "[object]" )
{
  json::object v{ { "x", "y" }, { "t", "u" } };

  REQUIRE( v["x"].is_string() == true );
  REQUIRE( v["x"].as_string() == "y" );
开发者ID:bebac,项目名称:clang-goto,代码行数:31,代码来源:json_test.cpp


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