<commit_before>JSON Editor
===========

JSON Schema -> HTML Editor -> JSON

If you have structured JSON data and need a web-based editor for it, JSON Editor can help you out.

Define your data structure using JSON Schema and let JSON Editor do the rest.

Check out an example: http://rawgithub.com/jdorn/json-editor/master/example.html

Download the [production version][min] or the [development version][max].

[min]: https://raw.github.com/jdorn/json-editor/master/dist/jquery.jsoneditor.min.js
[max]: https://raw.github.com/jdorn/json-editor/master/dist/jquery.jsoneditor.js

Requirements
-----------------

*  A recent version of jQuery
*  A modern browser

### Optional Requirements

*  A javascript template engine for macro support (Mustache, Underscore, Hogan, Handlebars, Swig, Markup, or EJS)
*  A compatible CSS Framework for styling (bootstrap 2/3, foundation 3/4/5, or jqueryui)

Usage
--------------

### Initialize

```javascript
$("#editor_holder").jsoneditor({
  schema: {
    type: "object",
    properties: {
      name: {
        type: "string"
      }
    }
  }
});
```

### Get/Set Value

```javascript
// Set the editor's value with a JSON object
$("#editor_holder").jsoneditor('value',{name: "<NAME>"});

// Get the editor's current value as a JSON object
var value = $("#editor_holder").jsoneditor('value');
console.log(value.name) // Will log "<NAME>"
```

### Validate

When feasible, JSON Editor won't let users enter invalid data.  
However, in some cases it is still possible to enter data that doesn't validate against the schema.
For those instances, you can use the `validate` method to check if the data is valid or not.

```javascript
// Validate the editor's current value against the schema
$("#editor_holder").jsoneditor('validate',function(errors) {
  if(errors) {
    // if it's not valid, errors will contain an array of objects, each with a `path` and `message` property
    console.log(errors);
  }
  else {
    // It's valid!
  }
});
```

### Listen for Changes

The `change` event is fired whenever the editor's value changes.  When using macro templates, multiple `change` events may fire in quick succession.

```javascript
$("#editor_holder").on('change',function() {});
```

### Destroy

This removes the editor HTML from the DOM and prepares everything for garbage collection.

```javascript
$("#editor_holder").jsoneditor('destroy');
```

JSON Schema Support
-----------------
JSON Editor supports a subset of the JSON Schema draft specification.

The following JSON schema keywords are supported.  All other keywords from the specification will be ignored.

*  default
*  definitions
*  description
*  enum (for type `string` only)
*  exclusiveMaximum
*  exclusiveMinimum
*  format
*  id
*  items
*  maxItems
*  maximum
*  maxLength
*  minItems
*  minimum
*  minLength
*  multipleOf
*  pattern
*  properties
*  title
*  type
*  uniqueItems
*  $ref

Most of these keywords behave as described in the specification, but several have caveats, which are described below.

In addition, there are a few custom keywords supported which are not in the spefication:

*  editor
*  options
*  template
*  vars

### Types

The following schema types are supported:

*  array
*  boolean
*  integer
*  number
*  object
*  string

Compound types are not supported.

### Arrays

JSON Editor only supports arrays with a single `items` schema.  In other words, every element in the array must have the same structure.  For example:

```json
{
  "type": "array",
  "items": {
    "type": "object",
    "parameters": {
      "name": {
        "type": "string"
      }
    }
  }
}
```
### References and Definitions

JSON Editor supports references to external urls and local definitions.  Here's an example showing both:

```json
{
  "type": "object",
  "properties": {
    "name": {
      "title": "<NAME>",
      "$ref": "#/definitions/name"
    },
    "location": {
      "$ref": "http://mydomain.com/geo.json"
    }
  },
  "definitions": {
    "name": {
      "type": "string",
      "minLength": 5
    }
  }
}
```

Local references must point to the `definitions` object of the root node of the schema and can't be nested.  So, both `#/customkey/name` and `#definitions/name/first` will throw an exception.

External urls are loaded with an AJAX request, so they must either be on the same domain or have the correct HTTP cross domain headers.

The standard schemas hosted on http://json-schema.org/ do not have the correct cross domain headers and thus cannot be used with JSON Editor.  So, using `http://json-schema.org/geo` will fail.


### Formats
<commit_msg>Fix typo in README<commit_after>JSON Editor
===========

JSON Schema -> HTML Editor -> JSON

If you have structured JSON data and need a web-based editor for it, JSON Editor can help you out.

Define your data structure using JSON Schema and let JSON Editor do the rest.

Check out an example: http://rawgithub.com/jdorn/json-editor/master/example.html

Download the [production version][min] or the [development version][max].

[min]: https://raw.github.com/jdorn/json-editor/master/dist/jquery.jsoneditor.min.js
[max]: https://raw.github.com/jdorn/json-editor/master/dist/jquery.jsoneditor.js

Requirements
-----------------

*  A recent version of jQuery
*  A modern browser

### Optional Requirements

*  A javascript template engine for macro support (Mustache, Underscore, Hogan, Handlebars, Swig, Markup, or EJS)
*  A compatible CSS Framework for styling (bootstrap 2/3, foundation 3/4/5, or jqueryui)

Usage
--------------

### Initialize

```javascript
$("#editor_holder").jsoneditor({
  schema: {
    type: "object",
    properties: {
      name: {
        type: "string"
      }
    }
  }
});
```

### Get/Set Value

```javascript
// Set the editor's value with a JSON object
$("#editor_holder").jsoneditor('value',{name: "<NAME>"});

// Get the editor's current value as a JSON object
var value = $("#editor_holder").jsoneditor('value');
console.log(value.name) // Will log "<NAME>"
```

### Validate

When feasible, JSON Editor won't let users enter invalid data.  
However, in some cases it is still possible to enter data that doesn't validate against the schema.
For those instances, you can use the `validate` method to check if the data is valid or not.

```javascript
// Validate the editor's current value against the schema
$("#editor_holder").jsoneditor('validate',function(errors) {
  if(errors) {
    // if it's not valid, errors will contain an array of objects, each with a `path` and `message` property
    console.log(errors);
  }
  else {
    // It's valid!
  }
});
```

### Listen for Changes

The `change` event is fired whenever the editor's value changes.  When using macro templates, multiple `change` events may fire in quick succession.

```javascript
$("#editor_holder").on('change',function() {});
```

### Destroy

This removes the editor HTML from the DOM and prepares everything for garbage collection.

```javascript
$("#editor_holder").jsoneditor('destroy');
```

JSON Schema Support
-----------------
JSON Editor supports a subset of the JSON Schema draft specification.

The following JSON schema keywords are supported.  All other keywords from the specification will be ignored.

*  default
*  definitions
*  description
*  enum (for type `string` only)
*  exclusiveMaximum
*  exclusiveMinimum
*  format
*  id
*  items
*  maxItems
*  maximum
*  maxLength
*  minItems
*  minimum
*  minLength
*  multipleOf
*  pattern
*  properties
*  title
*  type
*  uniqueItems
*  $ref

Most of these keywords behave as described in the specification, but several have caveats, which are described below.

In addition, there are a few custom keywords supported which are not in the spefication:

*  editor
*  options
*  template
*  vars

### Types

The following schema types are supported:

*  array
*  boolean
*  integer
*  number
*  object
*  string

Compound types are not supported.

#### Arrays

JSON Editor only supports arrays with a single `items` schema.  In other words, every element in the array must have the same structure.  For example:

```json
{
  "type": "array",
  "items": {
    "type": "object",
    "parameters": {
      "name": {
        "type": "string"
      }
    }
  }
}
```
### References and Definitions

JSON Editor supports references to external urls and local definitions.  Here's an example showing both:

```json
{
  "type": "object",
  "properties": {
    "name": {
      "title": "Full Name",
      "$ref": "#/definitions/name"
    },
    "location": {
      "$ref": "http://mydomain.com/geo.json"
    }
  },
  "definitions": {
    "name": {
      "type": "string",
      "minLength": 5
    }
  }
}
```

Local references must point to the `definitions` object of the root node of the schema and can't be nested.  So, both `#/customkey/name` and `#/definitions/name/first` will throw an exception.

External urls are loaded with an AJAX request, so they must either be on the same domain or have the correct HTTP cross domain headers.

The standard schemas hosted on http://json-schema.org/ do not have the correct cross domain headers and thus cannot be used with JSON Editor.  So, using `http://json-schema.org/geo` will fail.


### Formats

{'fraction_non_alphanumeric': 0.12613981762917933, 'fraction_numerical': 0.0013026487190620929, 'mean_word_length': 3.489766081871345, 'pattern_counts': {'":': 34, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2288309', 'n_tokens_mistral': 2712, 'n_tokens_neox': 2635, 'n_words': 1050}