csvjson-csv2json
Advanced tools
Comparing version 5.0.5 to 5.0.6
@@ -64,2 +64,23 @@ (function() { | ||
function uniquify(keys) { | ||
var counts = {}; | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
if (counts[key] === undefined) { | ||
counts[key] = 0; | ||
} else { | ||
counts[key]++; | ||
} | ||
} | ||
var result = []; | ||
for (var i = keys.length-1; i >= 0; i--) { | ||
var key = keys[i]; | ||
if (counts[key] > 0) key = key + '__' + counts[key]--; | ||
result.unshift(key); | ||
} | ||
return result; | ||
} | ||
function convert(csv, options) { | ||
@@ -90,2 +111,4 @@ options || (options = {}); | ||
keys = uniquify(keys); | ||
var json = options.hash ? {} : []; | ||
@@ -92,0 +115,0 @@ for (var l = 0; l < a.length; l++) { |
{ | ||
"name": "csvjson-csv2json", | ||
"description": "Converts CSV to JSON. Powers the most used online tool CSVJSON https://www.csvjson.com/csv2json. Used by thousands everyday.", | ||
"version": "5.0.5", | ||
"version": "5.0.6", | ||
"author": "Martin Drapeau <martindrapeau@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [], |
40786
950