Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
pretty-json-stringify
Advanced tools
Readme
A naive function that adds customizeable indents to JSON data (pretty-prints JSON whitespace). You can define whether any object or array should either be collapsed to one line or expanded with one item on each line.
var JSONString = prettyJSONStringify(objectToStringify, params);
var prettyJSONStringify = require('pretty-json-stringify');
prettyJSONStringify({
simple : [1, 2, 3],
tooShort : [4],
doNotExpand : [5, 6, 7],
level1 : {
level2_1 : {
a : 1
},
level2_2containsExpanded : {
a : 1,
doExpand : ['expanded'] // If any portion of object contains something told to be expanded, parent
// object is expanded regardless of whether it is told to be expanded itself
},
level2_3 : {
a : 1
},
}
}, {
shouldExpand : function(object, level, key) {
if (key == 'doNotExpand') return false;
if (key == 'doExpand') return true;
if (Array.isArray(object) && object.length < 2) return false;
if (level >= 2) return false;
return true;
}
});
This returns
{
"simple" : [
1,
2,
3
],
"tooShort" : [4],
"doNotExpand" : [5, 6, 7],
"level1" : {
"level2_1" : { "a" : 1 },
"level2_2containsExpanded" : {
"a" : 1,
"doExpand" : [
"expanded"
]
},
"level2_3" : { "a" : 1 }
}
}
Also following "code-style" parameters can be applied (any passed string is inserted as is, it is user's responsibility to keep it valid whitespace):
tab
(default: 4 spaces)spaceBeforeColon
(default: 1 space)spaceAfterColon
(default: 1 space)spaceAfterComma
(default: 1 space)spaceInsideObject
(inserted after opening and before closing braces, default: 1 space)spaceInsideArray
(inserted after opening and before closing braces, default: empty string).If shouldExpand
parameter is not passed, it expands every object whose plain JSON is longer that 25 characters.
FAQs
A function that adds customizeable indents to JSON data
The npm package pretty-json-stringify receives a total of 1,087 weekly downloads. As such, pretty-json-stringify popularity was classified as popular.
We found that pretty-json-stringify 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.