Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
json-schema-defaults
Advanced tools
Generate JSON object from default values in JSON Schema
Works both in node and browser.
npm
npm install json-schema-defaults
bower
bower install json-schema-defaults
manual
Download lib/defaults.js
CommonJS (node.js)
var defaults = require('./path/to/index.js');
defaults({ ... });
RequireJS
// in require.js config
paths: {
'defaults': './path/to/lib/defaults.js'
}
// in a file
define(['defaults'], function(defaults) {
defaults({ ... });
});
standalone
window.jsonSchemaDefaults({ ... });
If the standalone version causes any conflict with existing jsonSchemaDefaults
global variable,
you can return back the original variable:
var defaults = window.jsonSchemaDefaults.noConflict();
// `window.jsonSchemaDefaults` now points to the original variable
// `defaults` points to this script
defaults({ ... });
Call defaults
with JSON Schema. The default values will be extracted as a JSON.
var json = defaults({
"title": "Album Options",
"type": "object",
"properties": {
"sort": {
"type": "string",
"default": "id"
},
"per_page": {
"default": 30,
"type": "integer"
}
}
});
// would return
{
sort: 'id',
per_page: 30
}
For more examples, see the tests.
Run tests
npm test
Or individually
# in node
./node_modules/.bin/jasmine-node test/
# in browser
./node_modules/karma/bin/karma start
FAQs
Generate JSON object from default values in JSON Schema
The npm package json-schema-defaults receives a total of 8,707 weekly downloads. As such, json-schema-defaults popularity was classified as popular.
We found that json-schema-defaults 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.