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.
json-align
Advanced tools
Readme
This module provides a function and a command-line script that pretty-print JSON strings with consecutive values aligned at the same column for improved readability.
Before:
{
"name": "json-align",
"author": "James Nylen <jnylen@gmail.com>",
"description": "Library and script to pretty-print JSON files with values aligned together.",
"version": "...",
"repository": {
"type": "git",
"url": "https://github.com/nylen/node-json-align"
},
...
After:
{
"name" : "json-align",
"author" : "James Nylen <jnylen@gmail.com>",
"description" : "Library and script to pretty-print JSON files with values aligned together.",
"version" : "...",
"repository" : {
"type" : "git",
"url" : "https://github.com/nylen/node-json-align"
},
...
Based on Douglas Crockford's json2.js
.
##Usage
In code (first do npm install json-align
):
JSON.stringifyAligned = require('json-align');
On the command line (first do sudo npm install -g json-align
):
json-align --help
The command-line script will output to stdout unless the -i
/--in-place
option is given.
##Parameters
JSON.stringifyAligned(obj, [replacer], [spaces], [alignAllValues])
// or
JSON.stringifyAligned(obj, alignAllValues, [spaces])
replacer
: Like in JSON.stringify
, this is a value transformation
function, or an array of properties to serialize.spaces
: Like in JSON.stringify
, a number of spaces (or string) to indent
by (the default is 4)alignAllValues
: By default, a new alignment group will be started each
time an array or object value is encountered. If this option is set to
true
, then each object will have all of its values aligned together.##Examples
JSON.stringifyAligned({abc: 1, defgh: 2})
{
"abc" : 1,
"defgh" : 2
}
JSON.stringifyAligned({abc: 1, defgh: [2,3,4], ijk: 5})
{
"abc" : 1,
"defgh" : [
2,
3,
4
],
"ijk" : 5 // Note that this value is not aligned with the first two,
// since there is an array or object value before it.
}
JSON.stringifyAligned({abc: 1, defgh: [2,3,4], ijk: 5}, null, 2, true)
{
"abc" : 1,
"defgh" : [
2,
3,
4
],
"ijk" : 5
}
FAQs
Library and script to pretty-print JSON files with values aligned together.
The npm package json-align receives a total of 1,027 weekly downloads. As such, json-align popularity was classified as popular.
We found that json-align 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.