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


C++ JsonObjectStream::getRoot方法代码示例

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


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

示例1: onAjaxNetworkList

void onAjaxNetworkList(HttpRequest &request, HttpResponse &response)
{
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();

	json["status"] = (bool)true;

	bool connected = WifiStation.isConnected();
	json["connected"] = connected;
	if (connected)
	{
		// Copy full string to JSON buffer memory
		json["network"]= WifiStation.getSSID();
	}

	JsonArray& netlist = json.createNestedArray("available");
	for (int i = 0; i < networks.count(); i++)
	{
		if (networks[i].hidden) continue;
		JsonObject &item = netlist.createNestedObject();
		item["id"] = (int)networks[i].getHashId();
		// Copy full string to JSON buffer memory
		item["title"] = networks[i].ssid;
		item["signal"] = networks[i].rssi;
		item["encryption"] = networks[i].getAuthorizationMethodName();
	}

	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
}
开发者ID:linlun,项目名称:SW-ESP8266_Lunch,代码行数:30,代码来源:application.cpp

示例2: onState

void onState(HttpRequest &request, HttpResponse &response)
{
	
	//systemTime = SystemClock.getSystemTimeString();
	
	int freq = request.getQueryParameter("value").toInt();
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["status"] = (bool)true;
	
//		String timeString = 
	
	json["time"] = SystemClock.now().toUnixTime();;
	json["mute"] = mute;
	json["source"] = source;
	json["mixing"] = mixing;
	json["enhance"] = enhance;
	json["volumeFR"] = 74-volumeFR;
	json["volumeFL"] = 74-volumeFL;	
	json["volumeRR"] = 74-volumeRR;
	json["volumeRL"] = 74-volumeRL;
	json["volumeCEN"] = 74-volumeCEN;
	json["volumeSW"] = 74-volumeSW;
	json["frequency"] = frequency;
	json["volumeALLCH"] = 74-volumeALLCH;
	json["power"] = power;
	response.setAllowCrossDomainOrigin("*");
	response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
	response.setHeader("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Request, X-Request, X-Requested-With");

	response.sendJsonObject(stream);
}
开发者ID:avtehnik,项目名称:esp8266-music-box,代码行数:32,代码来源:application.cpp

示例3: onAjaxNetworkList

void onAjaxNetworkList(HttpRequest &request, HttpResponse &response)
{
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();

	json["status"] = (bool)true;

	bool connected = WifiStation.isConnected();
	json["connected"] = connected;
	if (connected)
	{
		currentNetwork = WifiStation.getSSID();
		json["network"] = currentNetwork.c_str();
	}

	JsonArray& netlist = json.createNestedArray("available");
	for (int i = 0; i < networks.count(); i++)
	{
		//if (networks[i].hidden) continue;
		JsonObject &item = netlist.createNestedObject();
		//debugf("%s %s", test.c_str(), networks[i].ssid.c_str());
		item.add("id", (int)networks[i].getHashId());
		item.add("title", networks[i].ssid.c_str());
		item.add("signal", networks[i].rssi);
		item.add("encryption", networks[i].getAuthorizationMethodName());
	}

	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
}
开发者ID:bhasden,项目名称:yoovea,代码行数:30,代码来源:Wifi.cpp

示例4: onAjaxInput

void onAjaxInput(HttpRequest &request, HttpResponse &response)
{
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["status"] = (bool)true;

	String stringKey = "StringKey";
	String stringValue = "StringValue";

	json[stringKey] = stringValue;

    for( int i = 0; i < 11; i++)
    {
        char buff[3];
        itoa(i, buff, 10);
        String desiredString = "sensor_";
        desiredString += buff;
        json[desiredString] = desiredString;
    }


	JsonObject& gpio = json.createNestedObject("gpio");
	for (int i = 0; i < countInputs; i++)
		gpio[namesInput[i].c_str()] = digitalRead(inputs[i]);

	response.sendJsonObject(stream);
}
开发者ID:BorntraegerMarc,项目名称:Sming,代码行数:27,代码来源:application.cpp

示例5: web_cb_driver_pos

void web_cb_driver_pos(HttpRequest &request, HttpResponse &response) {
	debug("Driver pos command");
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["pos"] = driver_pos();
	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
	scanStatus = 1;
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:9,代码来源:utils.cpp

示例6: web_cb_connect

void web_cb_connect(HttpRequest &request, HttpResponse &response) {
	String ssid = request.getQueryParameter("ssid");
	bool ssidNeedPass = request.getQueryParameter("needPass");
	String pass = request.getQueryParameter("pass");

	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();

	json["result"] = (bool)false;

	if( (WifiStation.getConnectionStatus() == eSCS_GotIP) && !ssid.length() ){
		json["result"] = (bool)true;

		json.addCopy("ip", WifiStation.getIP().toString());
		json.addCopy("ssid", WifiStation.getSSID());
	} else {
		if( WifiStation.getConnectionStatus() == eSCS_Connecting ){
			debug("WIFI Connecting");
			if( WifiStation.isConnected() ){
				debug("WIFI Connected");
				json["connected"] = (bool)true;
			} else {
				debug("WIFI in connection");
				json["connectInProgress"] = (bool)true;
			}
		} else {
			if( WifiStation.isConnectionFailed() && !ssid.length() ){
				debug("Connection was failed");
				json["connectionFailed"] = WifiStation.getConnectionStatusName();
			} else {
				debug("Starting connection");

				if(ssid.length() <= 0){
					json["error"] = "Wrong SSID";
				} else {
					if( ssidNeedPass && (pass.length() <= 0) ){
						json["error"] = "Passowrd not specified";
					} else {
						debugf("Connectiong to network %s", ssid.c_str());
						WifiStation.enable(true);
						WifiStation.config(ssid, pass);

						AppSettings.ssid = ssid;
						AppSettings.password = pass;
						AppSettings.save();
						json["result"] = (bool)true;
					}
				}
			}
		}
	}

	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:55,代码来源:utils.cpp

示例7: web_cb_driver_backward

void web_cb_driver_backward(HttpRequest &request, HttpResponse &response) {
	debug("Driver backward command");
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["backward"] = 1;
	driver_stop();
	driver_bw();
	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
	scanStatus = 1;
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:11,代码来源:utils.cpp

示例8: web_cb_start_scan

void web_cb_start_scan(HttpRequest &request, HttpResponse &response) {
	debug("Running scan of networks");
	# FIXME Clear networks list wariable
	WifiStation.startScan(networkScanCompleted);
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["scanning"] = 1;
	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
	scanStatus = 1;
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:11,代码来源:utils.cpp

示例9: web_cb_driver_setpos

void web_cb_driver_setpos(HttpRequest &request, HttpResponse &response) {
	int curr_pos = driver_pos();
	int pos = request.getQueryParameter("pos").toInt();
	Serial.println( os_printf("Driver setpos %d command", pos) );
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	driver_stop();
	driver_set_pos( pos );
	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
	scanStatus = 1;
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:12,代码来源:utils.cpp

示例10: onAjaxFrequency

void onAjaxFrequency(HttpRequest &request, HttpResponse &response)
{
	int freq = request.getQueryParameter("value").toInt();
	System.setCpuFrequency((CpuFrequency)freq);

	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["status"] = (bool)true;
	json["value"] = (int)System.getCpuFrequency();

	response.sendJsonObject(stream);
}
开发者ID:BorntraegerMarc,项目名称:Sming,代码行数:12,代码来源:application.cpp

示例11: onMixing

void onMixing(HttpRequest &request, HttpResponse &response)
{
	setMixing(!mixing);
	
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["status"] = (bool)true;
	json["state"] = (bool)mixing;
	response.setAllowCrossDomainOrigin("*");
	response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
	response.setHeader("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Request, X-Request, X-Requested-With");
	response.sendJsonObject(stream);
}
开发者ID:avtehnik,项目名称:esp8266-music-box,代码行数:13,代码来源:application.cpp

示例12: onAjaxGetIP

void onAjaxGetIP(HttpRequest &request, HttpResponse &response)
{
	response.setHeader("Access-Control-Allow-Origin", "*");
	response.setHeader("Access-Control-Allow-Methods", "GET");
	response.setHeader("Access-Control-Allow-Headers", "Content-Type, X-Requested-With");

	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();

	json["ip"]= WifiStation.getIP().toString();

	response.sendJsonObject(stream);
}
开发者ID:ti8m,项目名称:IoTmeetsBusiness,代码行数:13,代码来源:application.cpp

示例13: onSource

void onSource(HttpRequest &request, HttpResponse &response)
{
	int source = request.getQueryParameter("source").toInt();
    setSource(source);
    
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	json["status"] = (bool)true;
	json["source"] = source;
	response.setAllowCrossDomainOrigin("*");
	response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
	response.setHeader("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Request, X-Request, X-Requested-With");
	response.sendJsonObject(stream);
}
开发者ID:avtehnik,项目名称:esp8266-music-box,代码行数:14,代码来源:application.cpp

示例14: web_cb_scan_status

void web_cb_scan_status(HttpRequest &request, HttpResponse &response) {
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();
	JsonArray& netlist = json.createNestedArray("available");
	for (int i = 0; i < networks.count(); i++) {
		JsonObject &item = netlist.createNestedObject();
		item.add("id", (int)networks[i].getHashId());
		item.add("title", networks[i].ssid.c_str());
		item.add("signal", networks[i].rssi);
		item.add("encryption", networks[i].getAuthorizationMethodName());
	}

	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
}
开发者ID:Bravo13,项目名称:esp_hello_world,代码行数:15,代码来源:utils.cpp

示例15: onAjaxConnect

void onAjaxConnect(HttpRequest &request, HttpResponse &response)
{
	JsonObjectStream* stream = new JsonObjectStream();
	JsonObject& json = stream->getRoot();

	String curNet = request.getPostParameter("network");
	String curPass = request.getPostParameter("password");

	bool updating = curNet.length() > 0 && (WifiStation.getSSID() != curNet || WifiStation.getPassword() != curPass);
	bool connectingNow = WifiStation.getConnectionStatus() == eSCS_Connecting || network.length() > 0;

	if (updating && connectingNow)
	{
		debugf("wrong action: %s %s, (updating: %d, connectingNow: %d)", network.c_str(), password.c_str(), updating, connectingNow);
		json["status"] = (bool)false;
		json["connected"] = (bool)false;
	}
	else
	{
		json["status"] = (bool)true;
		if (updating)
		{
			network = curNet;
			password = curPass;
			debugf("CONNECT TO: %s %s", network.c_str(), password.c_str());
			json["connected"] = false;
			connectionTimer.initializeMs(1200, makeConnection).startOnce();
		}
		else
		{
			json["connected"] = WifiStation.isConnected();
			debugf("Network already selected. Current status: %s", WifiStation.getConnectionStatusName());
		}
	}

	if (!updating && !connectingNow && WifiStation.isConnectionFailed())
		json["error"] = WifiStation.getConnectionStatusName();

	response.setAllowCrossDomainOrigin("*");
	response.sendJsonObject(stream);
}
开发者ID:bhasden,项目名称:yoovea,代码行数:41,代码来源:Wifi.cpp


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