diff --git a/jsoneditoronline/jsoneditoronline-tests.ts b/jsoneditoronline/jsoneditoronline-tests.ts new file mode 100644 index 000000000..ca5d614de --- /dev/null +++ b/jsoneditoronline/jsoneditoronline-tests.ts @@ -0,0 +1,19 @@ +// Tests for JSONEditorOnline type definitions +/// + +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); \ No newline at end of file diff --git a/jsoneditoronline/jsoneditoronline.d.ts b/jsoneditoronline/jsoneditoronline.d.ts new file mode 100644 index 000000000..1fffc1afb --- /dev/null +++ b/jsoneditoronline/jsoneditoronline.d.ts @@ -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 +// 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; +} \ No newline at end of file