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

220
Views
Referring JSON keys that are numbers

My JSON data stored in dataTest.json data goes as follows :

    "1":"value1",
    "2":"value2"
}

The above gives positive results in a validator.

Now if I want to use this data in a javascript program like

var data = require('./dataTest.json');
console.log(data.1)

I get an error saying

console.log(data.1)
            ^^^^^^^^^
SyntaxError: missing ) after argument list

But simply changing the first key to something like a1 instead of simply 1 and calling it like data.a1 fixes it.

For several reasons, I'd like to keep the keys as simple numbers. Is there any way to refer to such keys with numerical values?

about 4 years ago · Juan Pablo Isaza
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!