zll-json2csv
Advanced tools
| const json2csv=(json,del=",")=>{if(del=del||",","string"==typeof json&&(json=JSON.parse(json)),!Array.isArray(json))throw new Error("First argument must be an array");const keys=Object.keys(json[0]);let csv=`${keys.join(del)}\n`;return json.forEach(row=>{if(Object.keys(row).toString()!=keys.toString())throw new Error("All objects must have the same keys");const values=Object.values(row).join(del);csv+=`${values}\n`}),csv};"undefined"!=typeof module&&(module.exports=json2csv); |
+1
-1
| { | ||
| "name": "zll-json2csv", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Convert your js/json object/string into csv string", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
4433
12.14%8
14.29%2
100%