Document JsonTransactionFactory::serialize(
          const Transaction &transaction) {
        Document document;
        auto& allocator = document.GetAllocator();
        document.SetObject();

        Value signatures;
        signatures.SetArray();
        for (const auto &signature : transaction.signatures) {
          signatures.PushBack(
              Document(&allocator)
                  .CopyFrom(serializeSignature(signature), allocator),
              allocator);
        }
        document.AddMember("signatures", signatures, allocator);

        document.AddMember("created_ts", transaction.created_ts, allocator);
        document.AddMember("creator_account_id", transaction.creator_account_id, allocator);
        document.AddMember("tx_counter", transaction.tx_counter, allocator);


        Value commands;
        commands.SetArray();
        for (auto &&command : transaction.commands) {
          commands.PushBack(
              Document(&allocator)
                  .CopyFrom(factory_.serializeAbstractCommand(command),
                            allocator),
              allocator);
        }

        document.AddMember("commands", commands, allocator);

        return document;
      }
      Document JsonBlockFactory::serialize(const Block &block) {
        Document document;
        auto &allocator = document.GetAllocator();
        document.SetObject();

        Value signatures;
        signatures.SetArray();
        for (const auto &signature : block.sigs) {
          signatures.PushBack(serializeSignature(signature, allocator),
                              allocator);
        }
        document.AddMember("signatures", signatures, allocator);

        document.AddMember("created_ts", block.created_ts, allocator);
        document.AddMember("hash", block.hash.to_hexstring(), allocator);
        document.AddMember(
            "prev_hash", block.prev_hash.to_hexstring(), allocator);
        document.AddMember("height", block.height, allocator);
        document.AddMember("txs_number", block.txs_number, allocator);

        Value commands;
        commands.SetArray();
        for (auto &&transaction : block.transactions) {
          commands.PushBack(
              Document(&allocator)
                  .CopyFrom(factory_.serialize(transaction), allocator),
              allocator);
        }
        document.AddMember("transactions", commands, allocator);

        return document;
      }