コード例 #1
0
ファイル: Trajectory.cpp プロジェクト: gaberoo/mctraj
  void Trajectory::json(rapidjson::Writer<rapidjson::StringBuffer>& w) const {
    EpiState x(initialState);
    size_t ntrans = transitionCount();
    double time = 0.0;

    w.StartArray();

    w.StartObject(); {
      w.String("time"); w.Double(time);
      w.String("state"); w.StartArray(); {
        for (size_t j = 0; j < x.numStates(); ++j) w.Int(x[j]);
      } w.EndArray();
    }w.EndObject();

    for (size_t i = 0; i < ntrans; ++i) {
      x += transitions[i].getTrans();
      time += transitions[i].atTime();
      w.StartObject(); {
        w.String("time"); w.Double(time);
        w.String("state"); w.StartArray(); {
          for (size_t j = 0; j < x.numStates(); ++j) w.Int(x[j]);
        } w.EndArray();
      } w.EndObject();
    }

    w.EndArray();
  }
 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();
 }
コード例 #3
0
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();
}
コード例 #4
0
 inline void marshall_json(rapidjson::Writer<rapidjson::StringBuffer>& writer, const cluster_info& info)
 {
     writer.StartObject();
     writer.String("name"); marshall_json(writer, info.name);
     writer.String("type"); marshall_json(writer, info.type);
     writer.EndObject();
 };
コード例 #5
0
 inline void marshall_json(rapidjson::Writer<rapidjson::StringBuffer>& writer, const deploy_info& info)
 {
     writer.StartObject();
     writer.String("cluster"); marshall_json(writer, info.cluster);
     writer.String("error"); marshall_json(writer, info.error);
     writer.String("name"); marshall_json(writer, info.name);
     writer.String("package_id"); marshall_json(writer, info.package_id);
     writer.String("service_url"); marshall_json(writer, info.service_url);
     writer.String("status"); marshall_json(writer, info.status);
     writer.EndObject();
 };
コード例 #6
0
ファイル: ProtobufJSON.cpp プロジェクト: Lyill/TrinityCore
void Serializer::WriteMessage(google::protobuf::Message const& value)
{
    google::protobuf::Reflection const* reflection = value.GetReflection();
    std::vector<google::protobuf::FieldDescriptor const*> fields;
    reflection->ListFields(value, &fields);

    _writer.StartObject();
    for (std::size_t i = 0; i < fields.size(); ++i)
        WriteMessageField(value, fields[i]);

    _writer.EndObject();
}
コード例 #7
0
ファイル: Branch.cpp プロジェクト: BeardedPlatypus/nTiled
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();
}
コード例 #8
0
ファイル: copy.cpp プロジェクト: snapwire-media/arion
void Copy::serialize(rapidjson::PrettyWriter<rapidjson::StringBuffer>& writer) const
#else
void Copy::serialize(rapidjson::Writer<rapidjson::StringBuffer>& writer) const
#endif
{
  writer.StartObject();

  // Result
  writer.String("type");
  writer.String("copy");

  // Output URL
  writer.String("output_url");
  writer.String("file://" + mOutputFile);

  if (mStatus == CopyStatusSuccess)
  {
    // Result
    writer.String("result");
    writer.Bool(true);

  }
  else
  {
    // Result
    writer.String("result");
    writer.Bool(false);

    // Error message
    if ((mStatus == CopyStatusError) &&  !mErrorMessage.empty())
    {
      writer.String("error_message");
      writer.String(mErrorMessage);
    }
  }

  writer.EndObject();
}