pubkey / jsonschema-key-compression

Compress json-data based on its json-schema while still having valid json

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Further compaction

dobesv opened this issue · comments

Have you considered making the encoding even more efficient by omitted key names for required fields, altogether?

e.g.

{
    "firstName": "Corrine",
    "lastName": "Ziemann",
    "title": "Ms.",
    "gender": "f",
    "zipCode": 75963,
    "countryCode": "en",
    "birthYear": 1960,
    "active": false,
    "shoppingCartItems": [
        {
            "productNumber": 29857,
            "amount": 1
        },
        {
            "productNumber": 53409,
            "amount": 6
        }
    ]
}

could become

["Corrine", "Ziemann", "Mrs.", false, [
        [29857, 1],
        [53409, 6]
    ],{
    "gender": "f",
    "zipCode": 75963,
    "countryCode": "en",
    "birthYear": 1960
}
]

Assuming that gender, zipCode, etc. are optional and the other fields are marked as required.

It seems like this could reduce the file size quite significantly.

Also you could consider applying the compression of graphql-crunch, which re-uses prior values if they are repeated.

Sorry for the late reply.
Yes your proposal would increase the effiency. But also it would change the whole structure and make if impossible to keep compressQuery() working.
This module is mainly made to be used with NoSQL-Databases.