Skip to content

mrsteele/json-truncate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-truncate

A way to truncate a json object. Useful for circular referenced objects.

Status

npm Travis Coverage Status Dependency Status devDependency Status js-standard-style semantic-release npm

Install

npm install json-truncate --save

Usage

// You can add this as a static function on JSON.
JSON.truncate = require('json-truncate');

console.log(JSON.truncate(SomeDeepObject, 10));

Returns

You will get a proper truncated object that can now be written to a file if needed.

Arguments

  • obj - The Object that will be truncated.
  • maxDepth - (optional) The depth at which to stop building the valid json. Defaults to 10.

Licence

MIT