Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/riccardoscalco/promise-json-file-reader
- Owner: riccardoscalco
- License: mit
- Created: 2017-12-17T20:59:12.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-17T21:30:56.000Z (almost 7 years ago)
- Last Synced: 2024-09-14T23:07:07.190Z (19 days ago)
- Language: JavaScript
- Size: 50.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
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/)