Standardize a
package.jsonobject.
var standardize = require( '@stdlib/tools/pkg-json/standardize' );Standardizes a package.json object.
var pkg = {
'license': 'MIT',
'name': 'beep'
};
var out = standardize( pkg );
// returns {'name':'beep','license':'MIT'}To specify an alternative key order, provide an array of keys.
var pkg = {
'c': 1,
'b': 2,
'a': 3
};
var keys = [ 'b', 'a', 'c' ];
var out = standardize( pkg, keys );
// returns {'b':2,'a':3,'c':1}- The implementation relies on engines using insertion order for key ordering. This is not specified by the ECMAScript specification; however, most engines order keys according to insertion order.
var standardize = require( '@stdlib/tools/pkg-json/standardize' );
var pkg = require( './../package.json' );
var out = standardize( pkg );
console.dir( out );Usage: standardize-json [options] [json]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--keys k1,k2,k3,... Keys in order of insertion.$ standardize-json '{"license":"MIT","name":"beep"}'
{"name":"beep","license":"MIT"}To use as a standard stream,
$ echo '{"license":"MIT","name":"beep"}' | standardize-json
{"name":"beep","license":"MIT"}