本文整理汇总了C++中JsonObjectStream类的典型用法代码示例。如果您正苦于以下问题:C++ JsonObjectStream类的具体用法?C++ JsonObjectStream怎么用?C++ JsonObjectStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JsonObjectStream类的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}