Comments (5)
Any news? It kinda sucks to get a different result depending on whether you use a JSON lib or eval(). I still suggest dropping newline support until this is fixed in ECMAScript.
from json5.
Good question and thanks for the nudge!
I haven't taken any action yet, but instead of dropping newline support altogether (I think there's value in keeping it, e.g. for a build tool where inconsistency between browsers isn't an issue), how about I just update the documentation to explicitly call out this behavior for now?
In particular, is it good enough if the documentation encourages only using newline support like this?
{
this: "is a newline \
string where each newline backslash \
is preceded by a space, and \
each newline explicitly begins \
with *no* spaces."
}
Using newlines like this appears to work consistently across all browsers, and still adheres to the ES5 spec. Would that work for you?
Optionally or additionally, perhaps the compiler could warn or throw an error if it encounters newline usage not like this. But that might be unnecessary.
from json5.
Hey @Midar, sorry for the delay! But good news: this was fixed in V8 (to match other browsers and the ES5 spec) last year, and even Node actually seems to behave correctly when running in a file (rather than the REPL).
http://code.google.com/p/v8/issues/detail?id=2165
And indeed, the current multi-line string test case tests this behavior and passes in both Node and Chrome as well as Firefox. So I'm thinking the current behavior of this JSON5 implementation is just fine. Sound reasonable to you?
from json5.
Released in 0.2.0 FYI:
https://github.com/aseemk/json5/blob/develop/CHANGELOG.md#v020-code-diff
Edit: oops, what I meant was that I updated the readme example, at least, to put the whitespace before the newline rather than after. At least that will always work. But I'm pretty happy and confident now that the multi-line spec and implementation are both correct and consistent with every implementation out there now.
from json5.
I don't see any problem anymore now that node seems to be compatible to the rest, so yes, this can stay closed :).
from json5.
Related Issues (20)
- Module '"node_modules/json5/lib/index"' has no default export HOT 1
- Support Integers outside the range `[-(2**53)+1, (2**53)-1]` HOT 6
- SyntaxError when require()ing JSON5 file in Jest test HOT 1
- Prototype Pollution in JSON5 HOT 11
- json5 latest is now 1.0.2 on npmjs - intentional? HOT 3
- Support Template Literals using backticks? HOT 1
- Provide `exports` config in `packages.json`
- Multiline JSON doesn't multiline HOT 1
- add key property support ? HOT 1
- Add `comma-dangle` option HOT 7
- Online JSON5 Editor(Formatter) is misleading? HOT 2
- Use .substring() instead of the deprecated .substr()
- Cannot stringify "\u0000"
- transitive dependency 'minimist' needs to be updated by rebuilding HOT 1
- question: commented unreachable code HOT 10
- JSON5.stringify() option: `trailingCommas` HOT 3
- Focus on ESNext HOT 1
- CLI should process consecutive JSONs HOT 1
- migrate to ESModules HOT 3
- Missing LICENSE file in the repo of ver 0.4.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json5.