Skip to content

jpdevries/JSONarea

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

JSONarea

JSON Validated Textarea. Lightweight and without opinion.

If you are using a HTML <textarea> 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

// 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
  }
});

About

JSON Validated Textarea. Lightweight and Unopinionated.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published