function stringify
stringify(data: DataItem[],unnamed 1?: StringifyOptions): stringWrite data using CSV encoding.
Examples
Example 1
Example 1
import { Column, stringify, } from "@std/csv/stringify"; type Character = { age: number; name: { first: string; last: string; }; }; const data: Character[] = [ { age: 70, name: { first: "Rick", last: "Sanchez", }, }, { age: 14, name: { first: "Morty", last: "Smith", }, }, ]; let columns: Column[] = [ ["name", "first"], "age", ]; console.log(stringify(data, { columns })); // first,age // Rick,70 // Morty,14
Parameters
data: DataItem[]The source data to stringify. It's an array of items which are plain objects or arrays.
DataItem: Record<string, unknown> | unknown[]
const data = [ { name: "Deno", repo: { org: "denoland", name: "deno" }, runsOn: ["Rust", "TypeScript"], }, ];
optional
unnamed 1: StringifyOptions