Repository navigation
Conversation
|
Thanks for your first-time contribution, @lifuzu! I'm personally pretty wary of supporting functions in JSON5, as they pretty firmly move us away from being a data format to now supporting arbitrary behaviors. I know there are use cases, but I'd say for anything non-trivial, if you need functions, you might be better off just using JS directly rather than JSON5. The other major problem with them is that they'll only work on JS runtimes. These days there are JSON5 parsers for other platforms too. So I don't think we'll be able to merge this, but your thoughts/questions/etc. welcome! |
|
@aseemk Thanks for the quick feedback. I totally understand what you are wary of. Actually, the reason why I put function as a value into JSON is not to execute the code (yes, I will have another engine to take care of that part), just extract the code as a string. With this way we exactly use JSON as a data exchange carrier. In fact, without function we could use string to pass the function, but not human friendly. For JS runtime problem, I think JS (function as the first class citizen, ref: http://ryanchristiani.com/functions-as-first-class-citizens-in-javascript/) is a great language for learning and using for all kinds of work. Some platforms have their JS interpreter (https://github.com/robertkrimen/otto, for go language). Besides, since function is not a mandatory, any other platforms could ignore if they don't want to have. I am trying to combine the feature together with the best flavor of JSON I think so far. If it is not really fit for the initial design principle, I will have another repo to maintain the feature. And again I will continue to contribute something here once I have. :-) |
|
Hey, everyone. I'm going to close this issue because it is incompatible with the official specification. If you would like to continue this discussion, please open an issue on the official specification repository. Please see the new issues template for more information. Thanks. |
to support function as a value