Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, https, ftp, s3, gs, or a local path. Both relative and absolute paths are supported
An input file object is also supported in the browser.
options
Object
Configuration options for reading JSON files. Supported options:
{
method: The HTTP method to use.
headers: Additional headers to send with the request if reading JSON from remote url. Supports all the node-fetch options in Nodejs, and all fetch options in browsers.
}
{
method: "GET"
}
The readJSON method can read JSON files from a local disk, over the internet, or directly from input file objects.
Reading JSON files from local disk
Node.js
1
const dfd =require("danfojs-node")
2
3
dfd.readJSON("./user_names.json")
4
.then(df=>{
5
6
df.head().print()
7
8
}).catch(err=>{
9
console.log(err);
10
})
Copied!
Reading JSON files from a URL
By specifying a valid URL, you can load JSON files from any location: