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.

Feat: use JSON5 instead of JSON.parse for friendly JSON syntax

See original GitHub issue

json5

{
  // comments
  unquoted: 'and you can quote me on that',
  singleQuotes: 'I can use "double quotes" here',
  lineBreaks: "Look, Mom! \
No \\n's!",
  hexadecimal: 0xdecaf,
  leadingDecimalPoint: .8675309, andTrailing: 8675309.,
  positiveSign: +1,
  trailingComma: 'in objects', andIn: ['arrays',],
  "backwardsCompatible": "with JSON",
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
davidtheclarkcommented, Mar 24, 2018

I was not planning on using require for JSON files. I don’t think there’s a need.

I am not interested in going down a rabbit hole to support “other flavors of json”. The request to parse multiple flavors of JS opens the door to more than enough flexibility, I think. And YAML provides opportunity for comments outside of JS files.

If there’s some strong argument about why JSON5 is a superior config format in common situations, not just an arbitrary personal preference, I’d consider reopening this issue.

1reaction
olsonpmcommented, Mar 23, 2018

i think there’s work toward using require instead of parsing the file as a string. We’ll then allow consumers to pass their own require function. This is mainly to support es modules but your use-case will be covered here as well.

Anyway we can leave this issue open till that’s finished

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON5 – JSON for Humans | JSON5
This JavaScript library is a reference implementation for JSON5 parsing and serialization, and is directly used in many of the popular projects mentioned...
Read more >
JSON parsing | Can I use... Support tables for HTML5, CSS3, etc
Method of converting JavaScript objects to JSON strings and JSON back to objects using JSON.stringify() and JSON.parse(). Usage % of. all users, all...
Read more >
JSON.parse() - JavaScript - MDN Web Docs
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string.
Read more >
Can comments be used in JSON? - Stack Overflow
No. JSON is data-only. If you include a comment, then it must be data too. You could have a designated data element called...
Read more >
Json image viewer - Veiled Mirror
Beautify JSON online using this tool to format your json, json output, ... with an online Javascript parser, featuring tree view and syntax...
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