New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

8

lib/jsonCommand.js

@@ -90,4 +90,4 @@ var util = require("util"),

return JSON.stringify(obj, null, 2)
.replace(/ ?([[{,])\n ( *)(?: )/gm, '\n$2$1 ')
.replace(/(^|, ?)\n *{/gm, '$1{');
.replace(/ ?([[{,])\n ( *)(?: )/gm, '\n$2$1 ') // trailing->leading ,-{-[s
.replace(/(^|[[{,] ?)\n */gm, '$1'); // cuddle brackets/braces/array items
};

@@ -233,3 +233,3 @@

vm.runInNewContext(this.transformedKeys[i].newKey +
" = " + this.transformedKeys[i].oldKey, parsedObject)
" = " + this.transformedKeys[i].oldKey, parsedObject);
}

@@ -482,3 +482,1 @@ catch (ex) {

};
{ "name": "json"
, "version": "0.0.13"
, "version": "0.0.14"
, "engines": [ "node >=0.4.0" ]

@@ -14,2 +14,5 @@ , "description": "JSON command line processing toolkit."

, "bin" : { "json" : "./bin/json.js" }
, "scripts":
{ "test" : "node test/test.js"
}
}

@@ -59,2 +59,4 @@ var assert = require("assert"),

"createRequestedKeys does not add null for 0 to object");
delete testObj.newKey;
})();

@@ -71,3 +73,3 @@

var jsonC = new JSON.Command();
jsonC = new JSON.Command();
jsonC.processArgs([ "-c", "(user.name == 'foo')"]);

@@ -144,4 +146,23 @@

(function testDiffFriendly() {
printTestName("testLeadingComma");
var jsonC = new JSON.Command();
jsonC.processArgs([ "-," ]);
assert.equal(jsonC.stringify(testObj),
'{ "id": 19375093\n, "text": "who knows"\n, "user":\n { "id": 1310571\n , "name": "foo"\n }\n, "arr1":\n [ "a"\n , "b"\n , "c"\n ]\n, "obj1":\n { "arr2":\n [ "d"\n , "e"\n , "f"\n ]\n }\n, "created_at": 127817599\n, "zero": 0\n}',
"Leading-comma output selection works and formats test object correctly");
assert.equal(jsonC.stringify([[]]), "[ []\n]",
"Leading-comma output nests arrays correctly");
assert.equal(jsonC.stringify({"":[{"deep":{"null":null}}]}),
'{ "":\n [ { "deep":\n { "null": null\n }\n }\n ]\n}',
"Leading-comma output nests deep object/array combinations correctly");
})();
})();
console.log("\nAll tests passed!\n");
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc