Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Convert JSON structure to plain text, perfect as a content negotiation fallback in REST APIs
JSON in, Plain text out.
The json2plain module was written as a suitable final fallback for a REST API doing automatic content negotiation.
$ npm install json2plain
var json2plain = require('json2plain');
var plain = json2plain(json, options);
json
- Can be a JSON Object or valid JSON String.options
- Optional Object, options are listed below.var json2plain = require('json2plain');
var json = {
"code": 7489394874,
"error": "It don't workie",
"description": "Someone broke it."
};
var plain = json2plain(json);
console.log(plain);
Code: 7489394874
Error: It don't workie
Description: Someone broke it.
var json2plain = require('json2plain');
var json = {
hello: "world",
number: 48392,
array: [
'string',
3948484,
true,
'string'
], "object": {
"string": "hello again",
"another": {
"hey": "there"
}
}
};
function ucFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
var options = {
list: '* ',
indent: ' ',
separator: '\t=\t',
formatKey: ucFirst,
formatValue: ucFirst
};
var plain = json2plain(json, options);
console.log(plain);
Hello = World
Number = 48392
Array =
* String
* 3948484
* True
* String
Object =
String = Hello again
Another =
Hey = There
depth
{Number} - amount of indentation to start with, defaults to 1.newline
{String} - string to use for newline, defaults to '\n'.indent
{String} - indentation, defaults to two spaces: ' '.separator
{String} - used to separate key from value, default: ': '.prefix
{String} - inserted before the output, defaults to '\n'.suffix
{String} - appended to the final output, defaults to '\n'.list
{String} - 'numbered' will list numbered array keys, defaults to '- '.formatKey
{Function} - format the keys: function(key){return key.toUpperCase()}..formatVal
{Function} - format the values: function(val) {return val}.Please see the examples folder for working examples of json2plain in action.
(The MIT License)
Copyright (c) 2012 Jarrad Seers <jarrad@jarradseers.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Convert JSON structure to plain text, perfect as a content negotiation fallback in REST APIs
The npm package json2plain receives a total of 4 weekly downloads. As such, json2plain popularity was classified as not popular.
We found that json2plain 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.