Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/riccardoscalco/promise-json-file-reader

Read and parse a File Object with mimetype application/json in browser.
https://github.com/riccardoscalco/promise-json-file-reader

Last synced: 2 days ago
JSON representation

Read and parse a File Object with mimetype application/json in browser.

Awesome Lists containing this project

README

        

# promise-json-file-reader

> Read and parse a File Object with mimetype application/json in browser.

## File Object

Tag `` with `type="file"` let the user choose a file from file system, and the user can access the selected file with the File API.

## Install

```
$ npm install --save promise-json-file-reader
```

## Usage as module

```js
import promiseJsonFileReader from 'promise-json-file-reader';

const file = document.querySelector('input[type=file]').files[0];

promiseJsonFileReader(file)
.then(data => console.log(data))
.catch(err => console.error(err));
```

## Usage with script tag

Copy file `./dist/promise-json-file-reader.js` in your project `lib` directory.

```html

```

```js
const promiseJsonFileReader = window.promiseJsonFileReader;

const file = document.querySelector('input[type=file]').files[0];

promiseJsonFileReader(file)
.then(data => console.log(data))
.catch(err => console.error(err));
```

## License

MIT © [Riccardo Scalco](https://riccardoscalco.github.io/)