Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!