Newton's Preposterous Miscalculation

    schemepack

    0.0.4 • Public • Published

    Schemepack

    JSON is very verbose object serializer. To reduce network bandwidth one can split JSON into schema and values.

    Subsequently the server needs to send the schema only once to the client. Each time new values are sent, the client can combine the schema and values into the original JSON.

    Installation:

    npm install schemepack
    

    Usage:

    var schemer = require("schemepack");
    

    Original JSON object:

    var json = {
        key: "value",
        arr: [1, 2, 3]
    };
    

    Extract JSON schema:

    var schema = schemepack.schema(json);
    console.log(schema);
    // ["key", "arr"]
    

    Extract JSON values:

    var values = schemepack.values(json);
    console.log(values);
    // ["value", [1, 2, 3]]
    

    Combine schema and values into the original object:

    json = schemepack.combine(schema, values);
    console.log(json);
    // {key:"value", arr:[1, 2, 3]}
    

    Bandwidth reduction depends on your original object form. For us, we see about 2x traffic reduction.

    Keywords

    none

    Install

    npm i schemepack

    DownloadsWeekly Downloads

    4

    Version

    0.0.4

    License

    none

    Last publish

    Collaborators

    • streamich