A JSON attributes renaming module for Play! Framework.
The original JSON Object
{
"oneLongAttribute" : "attribute",
"anotherLongAttribute" : "another attribute",
"oneAnotherLongAttribute" : "another once again attribute"
}
The encoded JSON Object
{
"g9" : "attribute",
"ga" : "another attribute",
"gb" : "another once again attribute"
}
This module provide two methods and 4 types of alias storage strategy:
- Local in memory (A singleton counter service and two alias mapping objects)
- File (Keep the data generated in the first strategy in a file so that it can be pre-loaded in the next start-up).
- Redis (Powered by Redis/ElastiCache).
- DynamoDB (Powered by DynamoDB).
Each time the encoder find a new JSON attribute, a unified Counter Service will generate a new count as a global unique BigInt type id for its attribute.
Step 2. Encoded by hashids
hashids is a kind of encoding strategy for BigInt data. So the unqiue counter number of each different attribute can be encoded by hashids to short (literally fix length of) String.
4 modes have been provided by dependency injection. You can just change the configure below in your application.conf file:
# JSON serial configuration
# 3 modes :
# - local
# - file (coming soon)
# - redis (coming soon)
# - dynamo (coming soon)
ms.module.json.alias.mode = "local"
- support local(in memory) mode.(external storage system will come soon)
- support embedded JsObject or JsArray encoding/decoding.
- unified counter service. (for unified Hashids)