
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
The JAC format makes it easy to convert to and from JSON and CSV file formats, while giving application developers a lot of flexibility to customize how easy it is to modify the CSV file for end users. Any JSON object can be represented as a JAC CSV.
.jac.csv
files are always valid CSVs.
An example JAC file is shown below:
path | . | name | dogs.0 | dogs.1 |
---|---|---|---|---|
myName | John | |||
friends.0 | Stacy | Rufus | ||
friends.1 | Paul | Mr. Fluffs | Whimpers |
When this file is converted into JSON, it becomes:
{
"myName": "John",
"friends": [
{
"name": "Stacy",
"dogs": ["Rufus"]
},
{
"name": "Paul",
"dogs": ["Mr. Fluffs", "Whimpers"]
}
]
}
npm install jac-format
const JAC = require("jac-format")
let csvString = JAC.toCSV(
{
fruit: [{ name: "apple" }, { name: "lemon" }],
},
{
rows: ["fruit.0", "fruit.1"], // optional
columns: ["name"], // optional
}
)
// "path,name\r\nfruit.0,apple\r\nfruit.1,lemon"
// ┌───┬───────────┬─────────┐
// │ │ A │ B │
// ├───┼───────────┼─────────┤
// │ 1 │ 'path' │ 'name' │
// │ 2 │ 'fruit.0' │ 'apple' │
// │ 3 │ 'fruit.1' │ 'lemon' │
// └───┴───────────┴─────────┘
// You can also use this
JAC.toJSON(csvString)
// > { "fruit": [{ "name": "apple" }, { "name": "lemon" }] }
// JAC.fromCSV === JAC.toJSON
// JAC.fromJSON === JAC.toCSV
pip install jac_format
import jac_format as jac
csv_string = jac.to_csv(
{
"fruit": [{ "name": "apple" }, { "name": "lemon" }],
},
rows=["fruit.0", "fruit.1"],
columns=["name"]
)
# > csv_string
# "path,name\r\nfruit.0,apple\r\nfruit.1,lemon"
# ┌───┬───────────┬─────────┐
# │ │ A │ B │
# ├───┼───────────┼─────────┤
# │ 1 │ 'path' │ 'name' │
# │ 2 │ 'fruit.0' │ 'apple' │
# │ 3 │ 'fruit.1' │ 'lemon' │
# └───┴───────────┴─────────┘
jac.to_json(csv_string)
# { "fruit": [{ "name": "apple" }, { "name": "lemon" }] }
jac_csv_path
or path
is the first column, first celljac_csv_path
cell)jac_csv_path
cell)a["1"].0
is equivalent to a["1"][0]
)null
Automatic indexing makes it easier to add and delete rows because index numbers don't need to be adjusted.
These tables are equivalent when converted to JSON:
path | . | name | dogs.* | dogs.* |
---|---|---|---|---|
myName | John | |||
friends.* | Stacy | Rufus | ||
friends.* | Paul | Mr. Fluffs | Whimpers |
path | . | name | dogs.0 | dogs.1 |
---|---|---|---|---|
myName | John | |||
friends.0 | Stacy | Rufus | ||
friends.1 | Paul | Mr. Fluffs | Whimpers |
If "*" are replaced by the smallest index in the path segment that's not already taken. There are two appropriate syntaxes, "[*]" or ".*". For a row, only the path segments in the row are considered (i.e. the header is converted into indicies without any information from the path
column).
You can also use the *
to refer to the last object created matching the prefix preceding the star. The example below is equivalent to the two tables above.
path | . | name |
---|---|---|
myName | John | |
friends.* | Stacy | |
friends.*.dogs.0 | Rufus | |
friends.* | Paul | |
friends.*.dogs.0 | Mr. Fluffs | |
friends.*.dogs.1 | Whimpers |
FAQs
JAC (JSON as CSV) Format Conversion
We found that jac-format demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.