Structured data explained
Does JSON allow integer keys?
No. In JSON, object member names must be strings in double quotes. Use arrays for index-based data instead of unquoted numeric keys.
![Flat minimalist diagram comparing JSON object and array on midnight background with code examples { '1': 'a' } and [ 'a', 'b' ]](https://media.checkmyschema.com/articles/mvo7kuup-uoals1/banner.jpg)
No. JSON object keys must be strings enclosed in double quotes. An object member name is a string per the JSON specification, so {"1": "a"} is valid JSON while {1: "a"} is not valid JSON RFC 8259. MDN also summarizes this rule as “property names must be double-quoted strings” MDN JSON reference.
What counts as a valid key in JSON?
The formal grammar defines an object member as member = string name-separator value, and states “A name is a string.” That means keys are always strings in double quotes RFC 8259.
Valid example
{
"1": "a",
"2": "b"
}
Invalid example (intentionally invalid JSON)
This is not valid JSON because the key is an unquoted number. A strict parser will fail expecting a string key:
{ 1: "a" }

When to use arrays instead of numeric-looking keys
If your data is an ordered sequence addressed by position, use an array. Arrays are designed for index-based access and avoid confusion over numeric-looking object keys.
Two shapes for a sequence of values
Object with numeric-looking string keys (valid JSON):
{
"0": "a",
"1": "b",
"2": "c"
}
Preferable array form for sequences:
["a", "b", "c"]
Related: can JSON contain NaN or Infinity?
No. The number grammar permits only finite decimal numbers. Infinity and NaN are not among the numeric tokens permitted by that grammar. RFC 8259. MDN also notes “NaN and Infinity are unsupported” in JSON MDN JSON reference.
Practical tip: some language runtimes allow NaN or Infinity in in-memory objects or nonstandard serializers, but any conforming JSON generator must not emit them. Replace such values with strings, null, or a sentinel agreed in your API contract before serializing.

Common parser gotchas
- Unquoted keys may be accepted in some language object literal syntax, but they are invalid in JSON text. Always quote keys.
- No trailing commas are allowed in objects or arrays. See: Can you have a trailing comma in JSON?
- Key comparisons are case-sensitive by value of the string. See: Are JSON keys case-sensitive?
Before you ship JSON with numeric-like keys
FAQ
Can I use integer keys if I quote them?
Yes. "1" is a string and therefore a valid JSON key. Just remember it is a string, not a number, and code should not assume numeric semantics for object member names RFC 8259.
Why does my language let me write {1: "a"}?
Some languages allow unquoted keys in their language object literals or auto-coerce them to strings. That does not make the same text valid JSON. When producing or validating JSON, keys must be quoted strings MDN JSON reference.
