JSON for ages is widely used format to keep configuration, exchange and store data etc. Zebkit uses JSON:

Zson features

Standard JSON format is quite simple and often cannot cover desired requirements. Zebkit extends JSON interpretation to support number of advanced features. The new JSON interpretation is called Zson (zebkit.Zson class), the number of new JSON features it introduces are the following:

    { "a" : { "@RegExp" : [ "[a-z]+", "i" ] } }
    { "test": 100 }
    {  "a": 12, "b": "%{a}" } 
    {  "a": { ".expr" : "10 + 10" } }
    {  "a" : 100,
       "b" : { "c": { "@Date" : [] } }, 
       "d" : "%{a}",
       "e" : "%{<json> http://test.com/embedded.json}",
       "f" : "%{e.m.k}"
    }

Where “embedded.json” is the following:

{  "m" : {  "k" : "Hello" } }

The result of the Zson loading described below:

The code that load the Zson us shown below:

new Zson().then(function("config.json", zson) {
    zson.root // handle fully loaded json 
});  

Configure JS objects with Zson

Zson can be used to configure classes and class instances with required properties. The way to do it looks as follow:

var A = zebkit.Class([
    function() {  // constructor
        this.b = this.a = null;
    },

    function setC(c) { // setter of property "c" 
        this.c = c;
    }
]); 
{  
    "a" : "value of property 'a'",
    "b" : { "@Date": [] },
    "c" : [ 1,2,3 ]
}
var a = new A();
// configure instance of class "A" with JSON
zebkit.Zson.then("config.json", a);  

The result is: