
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
@davidfig/json-depth
Advanced tools
Prettify JSON for output with a number of options, including inlining after a set depth
Prettify JSON for output with a number of options, including inlining after a set depth
My OCD forced me to create this. I wanted to edit JSON files prettified to a certain depth and I couldn't find an appropriate npm package. I added other options as well.
npm i @davidfig/json-depth
const fs = require('fs')
const jsonDepth = require('json-depth')
const data = { vehicles: ['cars', 'trucks', 'motorcycles', 'bicycles'], colors: ['red', 'green', 'blue']}
console.log(jsonDepth(data, { depth: 1 }))
/* RESULT:
{
"vehicles": ["cars", "trucks", "motorcycles", "bicycles"],
"colors": ["red", "green", "blue"]
}
*/
fs.writeFile('test/test-output.json', jsonDepth(DATA, { depth: 2 }), () =>
{
console.log('wrote file: test-output.json')
process.exit(0)
})
// prettify JSON with more options
function jsondepth(data, options)
name | type | default | description |
---|---|---|---|
data | object | data to be prettified | |
options | object | ||
options.depth | number | 3 | the number of depths to expand with options.eol characters |
options.indent | string | /t | a string or the number of spaces to indent each depth |
options.spaces | number | 0 | number of spaces to use instead of indent character |
options.eol | string | \n | end of line character |
options.spaceAfter | number | 1 | spaces after bracket, squiggly bracket, comma, or colon |
options.ignoreNull | boolean | false | ignore null |
options.ignoreUndefined | boolean | true | ignore undefined entries |
options.emptyArray | string | [] | replace empty array with this string |
options.emptyObject | string | {} | replace empty object with this string |
options.spaceInlineArray | boolean | false | whether to add a space at the beginning and end of an inline array |
options.spaceInlineObject | boolean | true | whether to add a space at the beginning and end of an inline object |
MIT License
(c) 2018 YOPEY YOPEY LLC by David Figatner
FAQs
Prettify JSON for output with a number of options, including inlining after a set depth
The npm package @davidfig/json-depth receives a total of 1 weekly downloads. As such, @davidfig/json-depth popularity was classified as not popular.
We found that @davidfig/json-depth 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.