本文整理汇总了C++中JsonWriter类的典型用法代码示例。如果您正苦于以下问题:C++ JsonWriter类的具体用法?C++ JsonWriter怎么用?C++ JsonWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JsonWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NullOutputStream
bool Id3v2TagFrameIO::getContractData(
ByteBuffer* b, uint32_t* uncompressed, uint32_t* compressed)
{
bool rval;
// create output stream
OutputStream* os = (b == NULL) ?
static_cast<OutputStream*>(new NullOutputStream()) :
static_cast<OutputStream*>(new ByteArrayOutputStream(b, false));
// zlib-compress data
Deflater def;
def.startDeflating(-1, false);
MutatorOutputStream mos(os, true, &def, false);
// produce JSON-formatted contract data
JsonWriter writer;
writer.setCompact(true);
rval = writer.write(mContract, &mos);
mos.close();
// store uncompressed bytes
if(uncompressed != NULL)
{
*uncompressed = def.getTotalInputBytes();
}
// store compressed bytes
if(compressed != NULL)
{
*compressed = def.getTotalOutputBytes();
}
return rval;
}
示例2:
void PlayFab::MatchmakerModels::FDeregisterGameResponse::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
writer->WriteObjectEnd();
}
示例3: WriteOptionalString
void WriteOptionalString(JsonWriter& w, T& k, const char* value)
{
if (value && value[0]) {
w.Key(k, sizeof(T) - 1);
w.String(value);
}
}
示例4: toJson
void toJson( JsonWriter &json, const _T & v ) const
{
json.startObject();
writeField<double>( json, width_s, "width", v.width );
writeField<double>( json, height_s, "height", v.height );
json.endObject();
}
示例5: getUserConfigPath
bool NodeConfigManager::saveUserConfig(UserId userId)
{
// FIXME: do we need locking for load/save/get/remove?
bool rval;
string path;
rval = getUserConfigPath(this, userId, path);
if(rval)
{
MO_CAT_DEBUG(BM_NODE_CAT,
"NodeConfigManager: save user config: id=%" PRIu64 ", path=%s",
userId, path.c_str());
// FIXME: how to check if config is "empty" of useful data?
Config c = getUserConfig(userId, true);
File file(path.c_str());
rval = file->mkdirs();
if(rval)
{
FileOutputStream fos(file);
JsonWriter writer;
writer.setCompact(false);
rval = writer.write(c, &fos);
fos.close();
}
}
return true;
}
示例6: writeJSON
void Backend::writeJSON(JsonWriter& json) const
{
json.beginObject()
.name("name")(name_)
.name("capacity")(capacity_)
.name("terminate-protection")(terminateProtection_)
.name("enabled")(enabled_)
.name("protocol")(protocol());
if (socketSpec_.isInet()) {
json.name("hostname")(socketSpec_.ipaddr().str())
.name("port")(socketSpec_.port());
} else {
json.name("path")(socketSpec_.local());
}
json.beginObject("stats");
json.name("load")(load_);
json.endObject();
if (healthMonitor_) {
json.name("health")(*healthMonitor_);
}
if (jsonWriteCallback_)
jsonWriteCallback_(this, json);
json.endObject();
}
示例7: save
void GameLevel::save(const std::string &levelFile) {
JsonWriter jsonWriter;
jsonWriter.writeTime();
jsonWriter.writeAuthor();
auto &writer = jsonWriter.getWriter();
writer.String(LEVEL_PALETTE_FILE);
writer.String(mPalette->getFileName());
writer.String(LEVEL_SPAWN_POS);
writer.Vec2(mHeroSpawnPos);
// Shadow groups.
writer.String(SHADOW_GROUP);
writer.StartArray();
for (auto sm : mShadows) {
sm->save(writer);
}
writer.EndArray();
// Sprites.
writer.String(GAME_SPRITES);
writer.StartArray();
for (auto sp : mSpriteList) {
sp->save(writer);
}
writer.EndArray();
// Effects.
writer.String(GAME_FX);
writer.StartArray();
for (auto sp : mEffects) {
writer.String(sp);
}
writer.EndArray();
// Blocks.
writer.String(LEVEL_BLOCK_ARRAY);
writer.StartArray();
for (auto &obj : mObjectManager->mObjects) {
if (obj.second->getID() == 0) {
continue;
}
obj.second->save(writer);
}
writer.EndArray();
jsonWriter.save(levelFile);
}
示例8: writeTo
void JsonArray::writeTo(JsonWriter &writer) const {
writer.beginArray();
const node_type *child = _firstNode;
while (child) {
child->content.writeTo(writer);
child = child->next;
if (!child) break;
writer.writeComma();
}
writer.endArray();
}
示例9: JsonWriteNonce
static void JsonWriteNonce(JsonWriter& writer, int nonce)
{
WriteKey(writer, "nonce");
char nonceBuffer[32];
NumberToString(nonceBuffer, nonce);
writer.String(nonceBuffer);
}
示例10: writeRegionEnumJSON
void PlayFab::MatchmakerModels::FStartGameRequest::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
writer->WriteIdentifierPrefix(TEXT("Build")); writer->WriteValue(Build);
writer->WriteIdentifierPrefix(TEXT("Region")); writeRegionEnumJSON(pfRegion, writer);
writer->WriteIdentifierPrefix(TEXT("GameMode")); writer->WriteValue(GameMode);
if(CustomCommandLineData.IsEmpty() == false) { writer->WriteIdentifierPrefix(TEXT("CustomCommandLineData")); writer->WriteValue(CustomCommandLineData); }
writer->WriteIdentifierPrefix(TEXT("ExternalMatchmakerEventEndpoint")); writer->WriteValue(ExternalMatchmakerEventEndpoint);
writer->WriteObjectEnd();
}
示例11: writeTo
void JsonVariant::writeTo(JsonWriter &writer) const {
if (is<const JsonArray &>())
as<const JsonArray &>().writeTo(writer);
else if (is<const JsonObject &>())
as<const JsonObject &>().writeTo(writer);
else if (is<const char *>())
writer.writeString(as<const char *>());
else if (is<const String *>())
writer.writeString(as<const String *>()->c_str());
else if (is<long>())
writer.writeLong(as<long>());
else if (is<bool>())
writer.writeBoolean(as<bool>());
else if (is<double>()) {
uint8_t decimals = static_cast<uint8_t>(_type - JSON_DOUBLE_0_DECIMALS);
writer.writeDouble(as<double>(), decimals);
}
}
示例12: writeTo
size_t JsonArray::writeTo(JsonWriter &writer) const {
size_t written = 0;
if((written = writer.beginArray()) == 0)
return 0;
const node_type *child = _firstNode;
size_t total = written;
while (child) {
if((written = child->content.writeTo(writer)) == 0) break;
total += written;
child = child->next;
if (!child) break;
if((written = writer.writeComma()) == 0) break;
total += written;
}
if(written)
total += writer.endArray();
return total;
}
示例13: writeDatetime
void PlayFab::MatchmakerModels::FVirtualCurrencyRechargeTime::writeJSON(JsonWriter& writer) const
{
writer->WriteObjectStart();
writer->WriteIdentifierPrefix(TEXT("SecondsToRecharge")); writer->WriteValue(SecondsToRecharge);
writer->WriteIdentifierPrefix(TEXT("RechargeTime")); writeDatetime(RechargeTime, writer);
writer->WriteIdentifierPrefix(TEXT("RechargeMax")); writer->WriteValue(RechargeMax);
writer->WriteObjectEnd();
}
示例14: writeTo
void JsonVariant::writeTo(JsonWriter &writer) const {
if (_type == JSON_ARRAY)
_content.asArray->writeTo(writer);
else if (_type == JSON_OBJECT)
_content.asObject->writeTo(writer);
else if (_type == JSON_STRING)
writer.writeString(_content.asString);
else if (_type == JSON_UNPARSED)
writer.writeRaw(_content.asString);
else if (_type == JSON_INTEGER)
writer.writeInteger(_content.asInteger);
else if (_type == JSON_BOOLEAN)
writer.writeBoolean(_content.asInteger != 0);
else if (_type >= JSON_FLOAT_0_DECIMALS) {
uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
writer.writeFloat(_content.asFloat, decimals);
}
}
示例15: CopyJsonValueToWriter
void CopyJsonValueToWriter( JsonWriter &Json, const FString& ValueName, const TSharedPtr<FJsonValue>& JsonValue )
{
if ( JsonValue->Type == EJson::String )
{
Json->WriteValue( ValueName, JsonValue->AsString() );
}
else if ( JsonValue->Type == EJson::Array )
{
if (ValueName.IsEmpty())
{
Json->WriteArrayStart();
}
else
{
Json->WriteArrayStart(ValueName);
}
const TArray<TSharedPtr<FJsonValue>>& Array = JsonValue->AsArray();
for ( const auto& ArrayValue : Array )
{
CopyJsonValueToWriter(Json, FString(), ArrayValue);
}
Json->WriteArrayEnd();
}
else if ( JsonValue->Type == EJson::Object )
{
if (ValueName.IsEmpty())
{
Json->WriteObjectStart();
}
else
{
Json->WriteObjectStart(ValueName);
}
const TSharedPtr<FJsonObject>& Object = JsonValue->AsObject();
for ( const auto& ObjectProperty : Object->Values)
{
CopyJsonValueToWriter(Json, ObjectProperty.Key, ObjectProperty.Value );
}
Json->WriteObjectEnd();
}
else
{
UE_LOG(LogChunkManifestGenerator, Warning, TEXT("Unrecognized json value type %d in object %s"), *UEnum::GetValueAsString(TEXT("Json.EJson"), JsonValue->Type), *ValueName)
}
}