Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda