Socket
Book a DemoInstallSign in
Socket

json-condenser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-condenser

Condenses JSON by shortening literals

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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

Keywords

compress

FAQs

Package last updated on 28 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts