https://github.com/jpdevries/jsonarea
JSON Validated Textarea. Lightweight and Unopinionated.
https://github.com/jpdevries/jsonarea
Last synced: 12 months ago
JSON representation
JSON Validated Textarea. Lightweight and Unopinionated.
- Host: GitHub
- URL: https://github.com/jpdevries/jsonarea
- Owner: jpdevries
- License: mit
- Created: 2016-02-13T03:26:09.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-21T11:20:37.000Z (about 10 years ago)
- Last Synced: 2025-02-15T03:32:49.149Z (about 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSONarea
JSON Validated Textarea. Lightweight and without opinion.
If you are using a HTML `` to allow your users to insert JSON, JSONarea was made just for you. JSONarea prides itself on what it does not do more than what it does do.
#### does:
- Listens to input events on a textarea and dispatches an update event indiciating whether or not the input is valid JSON.
- allows you to configure the events it listens to
- allows you to extend JSONarea with any number of Objects
#### doesn't:
- Hit the DOM
- require any third party dependencies
## Configuration
| Name | Description | Default
| ------------- |:-------------------------------------------------:| -----
| events | Array of events to listen to | `['change','keyup']`
| sourceObjects | Optional Array of objects to extend JSONArea with | `[]`
## Usage
```js
// do the deal
var myJSONArea = JSONArea(document.getElementById('json'),{
sourceObjects:[] // optional array of objects for JSONArea to inherit from
});
// then here's how you use JSONArea's update event
myJSONArea.getElement().addEventListener('update',function(e){
if(e.detail.isJSON) {
// do something
} else {
// do something else
}
});
```