Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
excel-2-json
Advanced tools
Expected use is offline translation of Excel data to JSON files, although async facilities are provided.
$ npm install excel-as-json --save-dev
convertExcel = require('excel-as-json').processFile;
convertExcel(<src>, <dst>, isColOriented, callback);
With these arguments, you can:
Convert a row/col oriented Excel file to JSON as a development task and log errors:
convertExcel = require('excel-as-json').processFile
convertExcel 'row.xlsx', 'row.json', false, (err, data) ->
if err then console.log "JSON conversion failure: #{err}"
convertExcel 'col.xlsx', 'col.json', true, (err, data) ->
if err then console.log "JSON conversion failure: #{err}"
Convert Excel file to an object tree and use that tree. Note that properly formatted data will convert to the same object tree whether row or column oriented.
convertExcel = require('excel-as-json').processFile
convertExcel 'row.xlsx', undefined, false, (err, data) ->
if err throw err
doSomethingInteresting data
convertExcel 'col.xlsx', undefined, true, (err, data) ->
if err throw err
doSomethingInteresting data
Excel stores tabular data. Converting that to JSON using only a couple of assumptions is straight-forward. Most interesting JSON contains nested lists and objects. How do you map a flat data square that is easy for anyone to edit into these nested lists and objects?
What is the easiest way to organize and edit your Excel data? Lists of simple objects seem a natural fit for a row oriented sheets. Single objects with more complex structure seem more naturally presented as column oriented sheets. Doesn't really matter which orientation you use, the module allows you to speciy a row or column orientation; basically, where your keys are located: row 0 or column 0.
Keys and values:
A simple, row oriented key
firstName |
---|
Jihad |
produces
[{
"firstName": "Jihad"
}]
A dotted key name looks like
address.street |
---|
12 Beaver Court |
and produces
[{
"address": {
"street": "12 Beaver Court"
}
}]
An indexed array key name looks like
phones[0].number |
---|
123.456.7890 |
and produces
[{
"phones": [{
"number": "123.456.7890"
}]
}]
An embedded array key name looks like this and has ';' delimited values
aliases[] |
---|
stormagedden;bob |
and produces
[{
"aliases": [
"stormagedden",
"bob"
]
}]
A more complete row oriented example
firstName | lastName | address.street | address.city | address.state | address.zip |
---|---|---|---|---|---|
Jihad | Saladin | 12 Beaver Court | Snowmass | CO | 81615 |
Marcus | Rivapoli | 16 Vail Rd | Vail | CO | 81657 |
would produce
[{
"firstName": "Jihad",
"lastName": "Saladin",
"address": {
"street": "12 Beaver Court",
"city": "Snowmass",
"state": "CO",
"zip": "81615"
}
},
{
"firstName": "Marcus",
"lastName": "Rivapoli",
"address": {
"street": "16 Vail Rd",
"city": "Vail",
"state": "CO",
"zip": "81657"
}
}]
You can do something similar in column oriented sheets. Note that indexed and flat arrays are added.
firstName | Jihad | Marcus |
---|---|---|
lastName | Saladin | Rivapoli |
address.street | 12 Beaver Court | 16 Vail Rd |
address.city | Snowmass | Vail |
address.state | CO | CO |
address.zip | 81615 | 81657 |
phones[0].type | home | home |
phones[0].number | 123.456.7890 | 123.456.7891 |
phones[1].type | work | work |
phones[1].number | 098.765.4321 | 098.765.4322 |
aliases[] | stormagedden;bob | mac;markie |
would produce
[
{
"firstName": "Jihad",
"lastName": "Saladin",
"address": {
"street": "12 Beaver Court",
"city": "Snowmass",
"state": "CO",
"zip": "81615"
},
"phones": [
{
"type": "home",
"number": "123.456.7890"
},
{
"type": "work",
"number": "098.765.4321"
}
],
"aliases": [
"stormagedden",
"bob"
]
},
{
"firstName": "Marcus",
"lastName": "Rivapoli",
"address": {
"street": "16 Vail Rd",
"city": "Vail",
"state": "CO",
"zip": "81657"
},
"phones": [
{
"type": "home",
"number": "123.456.7891"
},
{
"type": "work",
"number": "098.765.4322"
}
],
"aliases": [
"mac",
"markie"
]
}
]
All values from the 'excel' package are returned as text. This module detects numbers and booleans and converts them to javascript types. Booleans must be text 'true' or 'false'. Excel FALSE and TRUE are provided from 'excel' as 0 and 1 - just too confusing.
During install (mac), you may see compiler warnings while installing the excel dependency - although questionable, they appear to be benign.
FAQs
Convert Excel data to JSON
The npm package excel-2-json receives a total of 1 weekly downloads. As such, excel-2-json popularity was classified as not popular.
We found that excel-2-json 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.