coston / json-to-csv-export

A function to easily generate csv downloads of your json data. ✨
https://json-to-csv-export.coston.io
MIT License
84 stars 24 forks source link

feat(#55): add support for Header Mapping #72

Closed amirGaouaou closed 1 month ago

amirGaouaou commented 1 month ago

Added an extra option for Headers

interface HeaderMapping {
  label: string;
  key: string;
}

See example here

// import jsonToCsvExport from "json-to-csv-export";
  const mockData = [
    {
      id: 1,
      firstName: "Sarajane",
      lastName: "Wheatman",
      email: "swheatman0@google.nl",
      language: "Zulu",
      ip: "40.98.252.240",
    },
    {
      id: 2,
      firstName: "Linell",
      lastName: "Humpherston",
      email: "lhumpherston1@google.com.br",
      language: "Czech",
      ip: "82.225.151.150",
    },
  ];

  const headers = [
    { key: "id", label: "Identifier" },
    { key: "firstName", label: "First Name" },
    { key: "lastName", label: "Last Name" },
    { key: "email", label: "Email Address" },
    { key: "language", label: "Language" },
    { key: "ip", label: "IP Address" },
  ];

  return (
    <button onClick={() => jsonToCsvExport({ data: mockData, headers })}>
      Download Data
    </button>
  );
vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
json-to-csv-export ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 9:15pm
github-actions[bot] commented 1 month ago

:tada: This PR is included in version 3.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: