load-object
is a useful node.js
utility package for loading data. load-object
loads data into a Javascript object from JSON, YAML, TOML, CBOR, Dhall, XML, HTML and Markdown both locally and remotely, thereby removing the need to manually pass the files to different parsers.
- Dhall will probably only work on Linux and if you have dhall-to-json installed as it depends on native bindings. A resolution is planned for this by rewriting in
Purescript
.
npm install load-object
import { load } from "load-object"
// Should have one of these extensions: .json, .yaml, .yml, .dhall, .toml, .md, .cbor
const filePath = "./openapi.json"
const object = load(filePath)
// Should have one of these extensions: .json, .yaml, .yml, .dhall, .toml, .md
const url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json"
const object = load(url)