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-compressor-for-csv
Advanced tools
Readme
npm install json-compressor-for-csv
const compressor = require('json-compressor-for-csv');
compressor.compress({
list: _uncompressed, // ARRAY only
splitter : "-" // default "-"
}, function (jsv) {
console.log("Compressed " + JSON.stringify(jsv, 0, 2));
});
let _uncompressed = [{
"firstName": "andrea",
"lastName": "giglio",
"games": [
{
"id": 0,
"code": "A"
}]
}];
Compressed
{
"partials": [
{
"firstName": "andrea",
"lastName": "giglio",
"games-id": 0,
"games-code": "A"
}
],
"allKeys": [
"firstName",
"lastName",
"games-id",
"games-code"
]
}
let _uncompressed = [
{
"firstName": "luca",
"lastName": "medici",
"games": [
{
"id": 0,
"code": "H",
"actions": [
{
"id": 0,
"code": "I"
}]
}]
},{
"firstName": "andrea",
"lastName": "giglio",
"games": [
{
"id": 0,
"code": "A"
},
{
"id": 1,
"code": "B",
"numer": 7
},
{
"id": 2,
"code": "C",
"actions": [
{
"id": 0,
"code": "I",
"numer": 8
}]
}]
}];
Compressed
{
"partials": [
{
"firstName": "luca",
"lastName": "medici",
"games-id": 0,
"games-code": "H",
"games-actions-id": 0,
"games-actions-code": "I"
},
{
"firstName": "andrea",
"lastName": "giglio",
"games-id": 0,
"games-code": "A"
},
{
"firstName": "andrea",
"lastName": "giglio",
"games-id": 1,
"games-code": "B",
"games-numer": 7
},
{
"firstName": "andrea",
"lastName": "giglio",
"games-id": 2,
"games-code": "C",
"games-actions-id": 0,
"games-actions-code": "I",
"games-actions-numer": 8
}
],
"allKeys": [
"firstName",
"lastName",
"games-id",
"games-code",
"games-actions-id",
"games-actions-code",
"games-numer",
"games-actions-numer"
]
}
You can convert the compressed json using json2csv
npm install json-compressor-for-csv
npm install json2csv
const compressor = require('json-compressor-for-csv'),
json2csv = require('json2csv');
compressor.compress({
list: _uncompressed
}, function (jsv) {
//console.log("COMPRESSED", jsv);
json2csv({
data: JSON.parse(JSON.stringify(jsv.partials)),
fields: jsv.allKeys,
del: ';'
},
function (err, csv) {
//console.log("CSV", csv);
});
});
> node test/test.js
> Refactory
> Fix Bug for 2nd level nested array
> @ DELIMITER will be set generic value
FAQs
Module compress JSON to be easily exported to CSV
The npm package json-compressor-for-csv receives a total of 2 weekly downloads. As such, json-compressor-for-csv popularity was classified as not popular.
We found that json-compressor-for-csv 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.