When designing an API, it’s easy to forget that not everyone has a cable modem. What if a client could easily request exactly the data it needed. That is what JSON Mask aims to do.
This is a tiny language and an engine for selecting specific parts of a JS object, hiding/masking the rest.
A code example helps to demonstrate how this works.
var mask = require('json-mask')
mask({p: {a: 1, b: 2}, z: 1}, 'p/a,z') // {p: {a: 1}, z: 1}
JSON Mask seems like an interesting way to reduce the amount of data we send down the pipes.
Subscribe to The Changelog Weekly - our free weekly email covering everything that hits our open source radar.
The post Quickly reduce the amount of data your node API returns appeared first on The Changelog.