本文整理汇总了C++中JsonArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::begin方法的具体用法?C++ JsonArray::begin怎么用?C++ JsonArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readRooms
void ConfigurationReader::readRooms(JsonArray& rooms, Actor* actor) {
char *name;
Room *room;
for(JsonArray::iterator it=rooms.begin(); it!=rooms.end(); ++it)
{
JsonObject &jsonRoom = it->asObject();
name = jsonRoom[JSON_ROOM_NAME];
room = new Room(name);
JsonArray& jsonPoints = jsonRoom[JSON_POINTS];
readPoints(jsonPoints, room);
actor->addRoom(room);
}
}
示例2: run_iterator_test
static void run_iterator_test() {
StaticJsonDocument<JSON_ARRAY_SIZE(2)> doc;
JsonArray array = doc.to<JsonArray>();
array.add(12);
array.add(34);
TIterator it = array.begin();
TIterator end = array.end();
REQUIRE(end != it);
REQUIRE(12 == it->template as<int>());
REQUIRE(12 == static_cast<int>(*it));
++it;
REQUIRE(end != it);
REQUIRE(34 == it->template as<int>());
REQUIRE(34 == static_cast<int>(*it));
++it;
REQUIRE(end == it);
}
示例3: save
bool EffectHandler::save(JsonArray& array, uint8_t ID, const char * name)
{
//Serial.printf("[EffectHandler::save] Effect = %s, ID = %s\n", _name, ID);
int index = 0;
for (JsonArray::iterator it = array.begin(); it != array.end(); ++it) {
// *it contains the JsonVariant which can be casted as usuals
//const char* value = *it;
JsonObject& preset = *it;
if (preset.containsKey("ID")) {
if ( preset["ID"] == ID) {
array.removeAt(index) ;
DebugEffectHandlerf("[EffectHandler::save] preset %u removed\n", ID);
break;
}
}
index++;
// this also works:
//value = it->as<const char*>();
}
JsonObject& current = array.createNestedObject();
current["ID"] = ID;
current["name"] = name;
current["effect"] = _name;
if (addJson(current)) {
return true;
} else {
return false;
}
};
示例4: readPoints
void ConfigurationReader::readPoints(JsonArray& points, Room* room) {
char *name;
char *type;
Point *point;
int ctrPin, btnPin;
for(JsonArray::iterator it=points.begin(); it!=points.end(); ++it)
{
JsonObject &jsonPoint = it->asObject();
name = jsonPoint[JSON_POINT_NAME];
type = jsonPoint[JSON_POINT_TYPE];
ctrPin = jsonPoint[JSON_POINT_CTRPIN];
btnPin = jsonPoint[JSON_POINT_BTNPIN];
if (strcmp(type, JSON_POINT_TYPE_LIGHT) == 0) {
point = new LightPoint(ctrPin, btnPin, name);
room->addPoint(point);
point->printDiagnosticInfo();
}
}
}