Data Format Converter

Data Format Converter


This repository will be removed.

I felt that a lot of the functionality this module offers, either:

  • Didn't suit a use case
  • Solutions are already provided

Some main exaples are:

  • No one really gets raw data to parse into CSV. Especially in the format this module expects. I'm looking at you JSON to CSV. You would 99% of the time parse CSV data from a file.
  • JSON to CSV: No one really would have a CSV string. Yes it's beneficial to parse it to JSON, but with three lines of code, it can be done using std

Here is some information to use in it's place:

Parsing CSV

https://deno.land/std/encoding/ https://deno.land/x/csv

import { parse } from "https://deno.land/std/encoding/csv.ts"
// First get the csv data
const rawContent = Deno.readFileSync("./username.csv")
const decodedContent = new TextDecoder().decode(rawContent)
// Parse it
const parsed = await parse(decodedContent)
// parsed is already valid JSON. which results in a value that is exactly the same that CSV to JSON would produce
console.log(parsed)

Converting JSON to XML

Whilst there isn't any Deno alternative, you can combine NPM with a CDN, or use version 1.2.0 of this module to still provide the functionality.

Though, cases where you'd want to convert JSON to XML are very slim, only legacy API's choose to use XML over JSON.

Convertin XML to JSON

There doesn't seem to be an alternative as of yet (02/June/2020). Feel free to keep using v1.2.0 of this repository, but note there is a limitation with this:

  • It fails to parse if the xml character length if greater than 65,000