コード例 #1
0
void StartGameResponse::writeJSON(PFStringJsonWriter& writer)
{
    writer.StartObject();

    if (GameID.length() > 0) {
        writer.String("GameID");
        writer.String(GameID.c_str());
    }
    if (ServerHostname.length() > 0) {
        writer.String("ServerHostname");
        writer.String(ServerHostname.c_str());
    }
    writer.String("ServerPort");
    writer.Uint(ServerPort);

    writer.EndObject();
}
コード例 #2
0
void ItemInstance::writeJSON(PFStringJsonWriter& writer)
{
    writer.StartObject();

    if (ItemId.length() > 0) {
        writer.String("ItemId");
        writer.String(ItemId.c_str());
    }
    if (ItemInstanceId.length() > 0) {
        writer.String("ItemInstanceId");
        writer.String(ItemInstanceId.c_str());
    }
    if (ItemClass.length() > 0) {
        writer.String("ItemClass");
        writer.String(ItemClass.c_str());
    }
    if (PurchaseDate.notNull()) {
        writer.String("PurchaseDate");
        writeDatetime(PurchaseDate, writer);
    }
    if (Expiration.notNull()) {
        writer.String("Expiration");
        writeDatetime(Expiration, writer);
    }
    if (RemainingUses.notNull()) {
        writer.String("RemainingUses");
        writer.Int(RemainingUses);
    }
    if (UsesIncrementedBy.notNull()) {
        writer.String("UsesIncrementedBy");
        writer.Int(UsesIncrementedBy);
    }
    if (Annotation.length() > 0) {
        writer.String("Annotation");
        writer.String(Annotation.c_str());
    }
    if (CatalogVersion.length() > 0) {
        writer.String("CatalogVersion");
        writer.String(CatalogVersion.c_str());
    }
    if (BundleParent.length() > 0) {
        writer.String("BundleParent");
        writer.String(BundleParent.c_str());
    }
    if (DisplayName.length() > 0) {
        writer.String("DisplayName");
        writer.String(DisplayName.c_str());
    }
    if (UnitCurrency.length() > 0) {
        writer.String("UnitCurrency");
        writer.String(UnitCurrency.c_str());
    }
    writer.String("UnitPrice");
    writer.Uint(UnitPrice);
    if (!BundleContents.empty()) {
        writer.String("BundleContents");
        writer.StartArray();
        for (std::list<std::string>::iterator iter = BundleContents.begin(); iter != BundleContents.end(); iter++) {
            writer.String(iter->c_str());
        }
        writer.EndArray();
    }
    if (!CustomData.empty()) {
        writer.String("CustomData");
        writer.StartObject();
        for (std::map<std::string, std::string>::iterator iter = CustomData.begin(); iter != CustomData.end(); ++iter) {
            writer.String(iter->first.c_str());
            writer.String(iter->second.c_str());
        }
        writer.EndObject();
    }

    writer.EndObject();
}