v1.2.1
Data Format Converter for Deno: XML, JSON, CSV
Repository
Current version released
4 years ago
Versions
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