Comments (4)
Seems like a load of
haters
have clicked thedislike
button and given no comment to the reason why they hate the idea.
Thumbs down doesn't mean hate!
I am concerned with interoperability and narrowing the attack surface. Besides, I believe it's very easy to convert JSON5 to JSON on the HTTP server or application server at the point of transmission or earlier. For a static website it might be necessary to convert from JSON5 to JSON at deploy time using a build tool, but again this should be very easy.
Is there a use case where it would be useful to support JSON5 in import modules and it would also be difficult to convert to JSON before transmission?
Why choose to support JSON5 rather than HJSON, HOCON, or YAML, which are also strict JSON supersets?
from proposal-json-modules.
I do not think browsers natively can process JSON5. That might be a better place to start.
But I wish both could happen.
from proposal-json-modules.
I think JSON5 belongs in its own proposal.
For example, I would also want JSON.parse() and JSON.stringify() too
JSON.parse(str, { type: "json5" })
JSON.stringify(obj, { type: "json5" })
in addition to imports
import foo from "./foo.json" assert { type: "json5" };
import("foo.json", { assert: { type: "json5" } });
from proposal-json-modules.
Why choose to support JSON5 rather than HJSON, HOCON, or YAML, which are also strict JSON supersets?
I don't see how one precludes the others. I'd even like to see import string from './foo.txt' with { type: 'text', encoding: 'utf8' };
which would enable userland parsing for arbitrary formats. Or perhaps type: 'buffer'
.
Perhaps there could be some other extensibility mechanism for registering custom types. I imagine something like:
import 'js-yaml/register'; // some code to register custom type: yaml
import yaml from 'foo.yaml' with { type: 'yaml' };
I'm already accomplishing similar effects with webpack custom loaders, but I'd love to lose the dependency on an external bundler.
I do see the value in minimizing the scope of this proposal though. These should be follow-on proposals.
from proposal-json-modules.
Related Issues (17)
- Should JSON modules be frozen? HOT 29
- Stage 3 Review HOT 39
- Rationale for optional exception HOT 13
- Disallowing unused values HOT 2
- How would it work with a `<script>` HTML tag?
- Should JSON modules export Records/Tuples? HOT 2
- How should it work with CSP? HOT 1
- is json module allowed to have BOM? HOT 1
- The benefits of supporting JSON modules named exports would outweigh the downsides
- Simplify the type definition to 'as type' HOT 2
- Should named JSON module import be a parsing stage error? HOT 1
- Should JSON modules be frozen? HOT 22
- Request for feedback on draft proposal
- Implicite assert type HOT 2
- Reviver function upon import?
- Editorial notes
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 proposal-json-modules.