question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unquoted numeric keys in JSON output

See original GitHub issue

Prettier 1.19.1 Playground link

--parser json

Input:

{1:"a"}

Output:

{ 1: "a" }

Expected:

{ "1": "a" }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
lydellcommented, Dec 2, 2019

Sorry, I have no input on this. But I did think of #6132. Not sure if it is related.

0reactions
idler8commented, Dec 20, 2019

But this is also an invalid input {b:"a"} It can be processed like this {"b":"a"} Is it different from this? {1:"a"} @thorn0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing json, key without quotes - Stack Overflow
Check the JSON syntax. The only unquoted entities allowed except for numbers, objects and arrays are null , true , false . So...
Read more >
Must numeric JSON keys be quoted? - DBA Stack Exchange
I've noted that key-value values may be unquoted when numeric in TSQL JSON strings, but it seems the key component must always be...
Read more >
How to parse unquoted JSON with JavaScript - Quora
JSON can be loaded into a JavaScript object by using the JSON.parse() function. JSON is valid JavaScript, so it can be placed into...
Read more >
JSON Files - Spark 3.3.1 Documentation
Property Name Default Scope primitivesAsString false read prefersDecimal false read allowComments false read
Read more >
JSON methods, toJSON - The Modern JavaScript Tutorial
a number in JSON is just a number alert( JSON.stringify(1) ) // 1 // a ... There's another format named JSON5, which allows...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found