O'Reilly logo

JavaScript JSON Cookbook by Ray Rischpater

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compressing object-body content from a Node.js server built using the express module

If space is your primary concern when using JSON that has you considering a binary representation, you should seriously consider using compression instead. Compression can yield similar savings to a binary representation, it is implemented with gzip in most servers and HTTP clients, and can be added as a transparent layer after you've finished debugging your application. Here, we discuss adding object-body compression for JSON and other objects sent by the popular express server built on top of Node.js with the express module.

Getting ready

First, you need to make sure you've installed the express and compress modules:

npm install express
npm install compression ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required