Wrongly formats JSON with array as root as JS
See original GitHub issueWhen having a file which vs code recognizes as JSON (e.g. test.json
) which contains an array as the root entry it gets formatted as it would be a javascript file.
Input:
[{"test":"test"}]
Output:
;[{ test: 'test' }]
This does not seem to be a prettier
issue because running prettier
in the terminal on the .json
file directly does not cause the issue.
Custom Settings:
.prettierrc
:
arrowParens: always
singleQuote: true
parser: babylon
semi: false
printWidth: 100
trailingComma: es5
Relevant VS Code Settings:
...
"prettier.parser": "babylon",
"prettier.printWidth": 100,
"prettier.semi": false,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"eslint.autoFixOnSave": true,
"prettier.eslintIntegration": true,
...
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Set root JSON object value to array - Stack Overflow
So, simply JSON.parse(eventstring).Array1 . Is that what you're looking for? Incidentally, most "naked" primary data types are also ...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Solve common issues with JSON in SQL Server
I want to produce complex JSON with several arrays on the same level. FOR JSON PATH can create nested objects using paths, and...
Read more >RFC 7159: The JavaScript Object Notation (JSON) Data ...
JSON defines a small set of formatting rules for the portable representation of ... RFC 7159 JSON March 2014 The terms "object" and...
Read more >What Is JSON and How to Handle an “Unexpected Token” Error
Values can be strings, arrays, or any other data that can be ... JSON format is quite similar to JavaScript objects, but it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try removing “parser”: “babylon” from your config file
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.