Introducing a new JSON extension known as "JFON", designed to facilitate the transport of functions and array-properties.
JFON makes use of eval and is most suitable under the following conditions:
1) When your data originates from a trusted source (i.e., not user input or external sources), and
2) You are certain that there are no unexpected side effects when using "eval"
(specifically within the context of the function "fromJFON" on line 127 )
3) Adapting your application to utilize "functionless" JSON would be too time-consuming;
4) Since JFON was developed in just one day, it may require additional testing;
The concept behind JFON involves utilizing specific property names to encode functions and arrays similarly to how escape characters work with strings, using backslashes "\" for newline characters and "\\" to represent itself.
In JFON, the name "wrap" is designated for encoding functions and their corresponding structures: "wrap" : { "fun" : ... and "wrap" : { "esc" : ...
Take a look at the demo:
View the code (using commit 0.0.86):
https://github.com/lancelab/spaceen/blob/master/js/btb/JFON.js
Test it out: github.com/lancelab/spaceen/blob/master/js/btb/tests/jfon.htm
Additionally, there is another extension called "JWON" which incorporates features like JSON-comments, here-documents, and monkey-patching of JSONs:
github.com/lancelab/Boardspirator/blob/master/diary/play/tp/jwon.js