-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support JSON5 #14
Comments
I do not think browsers natively can process JSON5. That might be a better place to start. But I wish both could happen. |
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? |
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" } }); |
I don't see how one precludes the others. I'd even like to see 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. |
JSON5 basically allows comments in JSON and some harmless leniency -
https://json5.org/
type: "json5"
?The text was updated successfully, but these errors were encountered: