
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
deepjsontocsv
Advanced tools
A TypeScript utility for converting deeply nested JSON objects or arrays into CSV format. This library flattens nested objects and arrays, allowing you to easily generate CSV files from complex JSON structures.
A TypeScript utility for converting deeply nested JSON objects or arrays into CSV format. This library flattens nested objects and arrays, allowing you to easily generate CSV files from complex JSON structures.
You can install the package via npm:
npm install deepjsontocsv
Here’s an example of how to use the library:
import { jsonToCsv } from 'deepjsontocsv';
const jsonObject = {
album: "The White Stripes",
year: 1999,
US_peak_chart_post: "-",
main_actor: {
name: "Jack White",
birth: "1975",
},
actors: [
{
name: "Jack White",
birth: "1975",
},
],
};
const csvResult = jsonToCsv(jsonObject);
console.log(csvResult);
Output:
album,year,US_peak_chart_post,main_actor.name,main_actor.birth,actors[0].name,actors[0].birth
The White Stripes,1999,-,Jack White,1975,Jack White,1975
If you have an array of JSON objects, the library will handle it seamlessly:
const jsonArray = [
{
album: "The White Stripes",
year: 1999,
US_peak_chart_post: "-",
main_actor: {
name: "Jack White",
birth: "1975",
},
actors: [
{
name: "Jack White",
birth: "1975",
},
],
},
{
album: "De Stijl",
year: 2000,
US_peak_chart_post: "-",
},
];
const csvResult = jsonToCsv(jsonArray);
console.log(csvResult);
Output:
album,year,US_peak_chart_post,main_actor.name,main_actor.birth,actors[0].name,actors[0].birth
The White Stripes,1999,-,Jack White,1975,Jack White,1975
De Stijl,2000,-,,,,
The library gracefully handles undefined or missing fields, ensuring the output remains valid.
typescript
Copy code
const jsonArrayWithMissingFields = [
{
album: "De Stijl",
year: 2000,
US_peak_chart_post: "-",
},
];
const csvResult = jsonToCsv(jsonArrayWithMissingFields);
console.log(csvResult);
Output:
album,year,US_peak_chart_post
De Stijl,2000,-
jsonToCsv(json: JsonObject | JsonObject[]): string
json
: A single JSON object or an array of JSON objects to be converted into CSV.The following types are used by the library:
type JsonValue = string | number | boolean | null | undefined | JsonObject | JsonValue[];
interface JsonObject {
[key: string]: JsonValue;
}
actors
will be represented as actors[0].name
, actors[1].name
, etc.string
, number
, boolean
, null
, undefined
) are supported as leaf nodes in the JSON structure.This project is licensed under the MIT License.
FAQs
A TypeScript utility for converting deeply nested JSON objects or arrays into CSV format. This library flattens nested objects and arrays, allowing you to easily generate CSV files from complex JSON structures.
The npm package deepjsontocsv receives a total of 3 weekly downloads. As such, deepjsontocsv popularity was classified as not popular.
We found that deepjsontocsv demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.