
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
jsonc-compress
Advanced tools
One of the problems you can have developing rich internet applications (RIA) using Javascript is the amount of data being transported to and from the server. When data comes from server, this data could be GZipped, but this is not possible when the big amount of data comes from the browser to the server.
JSON-Compress has two differents approaches to reduce the size of the amount of data to be transported:
// Download from GitHub because this is not my original work
yarn add https://github.com/Alamantus/JSON-Compress.git
// or
npm install git+https://github.com/Alamantus/JSON-Compress.git
// Returns the JSONC object with the following methods.
var JSONC = require( 'json-compress' );
// Returns a JSON object but compressed.
var compressedJSON = JSONC.compress( json );
// Returns the original JSON object.
var json = JSONC.decompress( compressedJSON );
// Returns the LZW representation as string of the JSON object.
var lzwString = JSONC.pack( json );
// Returns the original JSON object.
var json = JSONC.unpack( gzippedString );
// Returns the LZW representation as string of the JSON object.
var lzwString = JSONC.pack( json, true );
// Returns the original JSON object.
var json = JSONC.unpack( gzippedString, true );
If compressing a JSON object that contains keys that are single characters, there may be a collision with those keys and the generated map keys of the compressed JSON object. The safest way to prevent this is to not use single-character keys, but when you need these short keys, you can use the collision prevention flag.
Using key/map collision prevention will slow down the compression of JSON objects, and it may slow it down significantly if the object is particularly lage. Be aware of this before using the options below.
// Returns a JSON object but compressed, ensuring that any
// single-character keys have no collision with the map.
var compressedJSON = JSONC.compress( json, true );
// Returns the LZW representation as string of the JSON object, ensuring
// that any single-character keys have no collision with the map.
var lzwString = JSONC.pack( json, true, true );
// Inject JSONC functions into global JSON object
require( 'json-compress' ).inject( JSON );
// Use JSONC functions directly from JSON object
var compressedJSON = JSON.compress( json );
var json = JSON.decompress( compressedJSON );
var lzwString = JSON.pack( json );
var json = JSON.unpack( lzwString );
FAQs
Compress your JSON to send and get a lot of data to/from server
The npm package jsonc-compress receives a total of 1 weekly downloads. As such, jsonc-compress popularity was classified as not popular.
We found that jsonc-compress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.