Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
Creating a ticket generating app to parse to a JSON

I need help from some of you experienced folks. I am attempting to generate tickets that hold metadata in JSON format. I am a fairly new developer. My idea in this is to take a user and have them create an event with x amount of tickets. The user or our company will then enter the standard input info (venue name, artist name, select seat numbers, sections etc). I want to be able to generate thousands of tickets, each with the correct info that reflects the venue. In general how should I go about this?

Below is me messing around with ways to do this, but I don't have a lot of experience as you can see. I was able to get the tickets to put in String info, but not have seat numbers iterate and increase etc.

import { watchFile, writeFile } from "fs";
import fs from "fs";

class BlockPass_`enter code here`PermanentData {
  constructor(venue_Name, artist_Name, genre) {
    this.venue_Name = venue_Name;
    this.artist_Name = artist_Name;
    this.genre = genre;
  }
}


let ticket_Omega = new BlockPass_PermanentData(
  "Catalyst",
  "As I Lay Dying",
  "Post-Hardcore Metal"
);


const maxTickets = 10;

function makeTickets(maxTickets) {
  const tickets = {};
  for (let i = 0; i < maxTickets; i++) {
    tickets[i] = ticket_Omega;
  }
  return tickets;
}

let tickets_Generated = makeTickets(maxTickets);


const ticket_MetaData = JSON.stringify(tickets_Generated);
console.log(ticket_MetaData);

writeFile("JSON/tickets_Omega.JSON", ticket_MetaData, function (err) {
  if (err) throw err;
  console.log("Omega Tickets generated. Begin Modifications.");
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The main issue with your code is that you are setting all your tickets to the same object (ticket_Omega). You probably want to generate a new object for every ticket.

I would do something like this instead:

class Event {
    constructor(venue_Name, artist_Name, genre) {
        this.venue_Name = venue_Name;
        this.artist_Name = artist_Name;
        this.genre = genre;
    }

    makeTickets(maxTickets) {
        const tickets = {};
        for (let i = 0; i < maxTickets; i++) {
            tickets[i] = {
                seatNumber: i,
                sold: false,
                venue_Name: this.venue_Name,
                artist_Name: this.artist_Name,
                genre: this.genre,
            };
        }
        return tickets;
    }
}

const some_event = new Event("Catalyst", "As I Lay Dying", "Post-Hardcore Metal");
let tickets = some_event.makeTickets(10);
console.log(tickets);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda