JSONEditorOnline type definitions and tests

Initial commit of JSONEditorOnline type definitions and tests.
This commit is contained in:
Vincent Bortone
2013-01-25 12:39:20 -05:00
parent d412e0129f
commit aaab0e11c1
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,19 @@
// Tests for JSONEditorOnline type definitions
///<reference path="jsoneditoronline.d.ts" />
var options:JSONEditorOptions = {
"search": true
};
var editor:JSONEditor = new JSONEditor(container, options);
var json:JSON = {
"Array": [1, 2, 3],
"Boolean": true,
"Null": null,
"Number": 123,
"Object": {"a": "b", "c": "d"},
"String": "Hello World"
};
editor.set(json);
editor.expandAll();
var json2:JSON = editor.get(json);
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for JSONEditorOnline
// JSON Editor Online is a tool to easily edit and format JSON online. JSON is displayed in a clear, editable treeview and in formatted plain text.
// Project: https://github.com/josdejong/jsoneditoronline
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface JSONEditorOptions {
change?: () => void;
history?: bool;
mode?: string;
name?: string;
search?: bool;
}
interface JSONEditor {
(container:HTMLElement, options?: JSONEditorOptions, json?: JSON): JSONEditor;
set(json: JSON, name?: string): void;
setName(name?: string): void;
get(): JSON;
getName(): string;
expandAll(): void;
collapseAll(): void;
}
interface JSONFormatterOptions {
change?: () => void;
indentation?: number;
}
interface JSONFormatter {
(container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor;
}