inline void Squirrel::serialize(rapidjson::Writer<rapidjson::StringBuffer>& writer) const { writer.StartObject(); writer.Key("key"); writer.Uint(key); writer.Key("name"); writer.String(name_); writer.Key("age"); writer.Uint(age_); writer.Key("occupation"); writer.String(occupation_); writer.Key("created_at"); long hest = created_at_; struct tm* tt = gmtime (&hest); char datebuf[32]; strftime(datebuf, sizeof datebuf, "%FT%TZ", tt); writer.String(datebuf); writer.EndObject(); }
void RequestActionReturnableLongPolling_GetZoneMediaList::addMediaListToJson(const std::string &_zoneUDN, std::vector<std::shared_ptr<Raumkernel::Media::Item::MediaItem>> &_mediaList, rapidjson::Writer<rapidjson::StringBuffer> &_jsonWriter) { _jsonWriter.StartObject(); _jsonWriter.Key("udn"); _jsonWriter.String(_zoneUDN.c_str()); _jsonWriter.Key("items"); _jsonWriter.StartArray(); for (auto mediaItem : _mediaList) { _jsonWriter.StartObject(); MediaItemJsonCreator::addJson(mediaItem, _jsonWriter); _jsonWriter.EndObject(); } _jsonWriter.EndArray(); _jsonWriter.EndObject(); }
void Branch::exportToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer) const { writer.StartObject(); writer.Key("type"); writer.String("branch"); writer.Key("sub-nodes"); writer.StartArray(); for (Node* p : this->sub_nodes) { p->exportToJson(writer); } writer.EndArray(); writer.EndObject(); }
void Serializer::WriteMessageField(google::protobuf::Message const& value, google::protobuf::FieldDescriptor const* field) { _writer.Key(field->name().c_str()); if (field->is_repeated()) { _writer.StartArray(); WriteRepeatedMessageField(value, field); _writer.EndArray(); } else WriteSimpleMessageField(value, field); }