json-condenser
Condenses JSON by shortening literals
Last updated 4 years ago by rstacruz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install json-condenser 
SYNC missed versions from official npm registry.

json-condenser

Condenses JSON by shortening literals and numbers

json-condenser makes JSON shorter but still (kind of) human-readable. Great for embedding JSON data in URLs.

const KEYS = ['id', 'name', 'email', 'role', 'admin']
const json = [{"id":1,"name":"John","email":"john@gmail.com","role":"admin"}]

let payload = condense(KEYS, json)
//=> [{e:1,f:"John",g:"john@gmail.com",h:i}]

expand(KEYS, payload)
//=> [{"id":1,"name":"John","email":"john@gmail.com","role":"admin"}]

Status

API

condense

condense(keys, json)

Condenses a JSON string json by shortening the keys in keys into letters.

  • keys (Array of strings) - key names to be abbreviated.
  • json (String) - A JSON string as given by JSON.stringify(). It should not have any whitespaces.

expand

expand(keys, condensedJson)

Expands an output of condense().

  • keys (Array of strings) - The same keys passed onto condense().
  • condensedJson (String) - The output of condense().

Thanks

json-condenser © 2016+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

Current Tags

  • 1.0.1                                ...           latest (4 years ago)

2 Versions

  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |