Added JSONFormatter interface and tests

This commit is contained in:
Vincent Bortone
2013-01-25 12:49:33 -05:00
parent aaab0e11c1
commit b29239b019
2 changed files with 22 additions and 1 deletions

View File

@@ -16,4 +16,20 @@ var json:JSON = {
editor.set(json);
editor.expandAll();
var json2:JSON = editor.get(json);
var jsonResult:JSON = editor.get(json);
var options2: JSONformatterOptions = {
"indentation": 2
};
var formatter:JSONFormatter = new JSONFormatter(container, options);
var json2:JSON = {
"Array": [1, 2, 3],
"Boolean": true,
"Null": null,
"Number": 123,
"Object": {"a": "b", "c": "d"},
"String": "Hello World"
};
formatter.set(json2);
var jsonResult2:JSON = formatter.get(json2);

View File

@@ -29,4 +29,9 @@ interface JSONFormatterOptions {
interface JSONFormatter {
(container:HTMLElement, options?: JSONFormatterOptions, json?: JSON): JSONEditor;
(container:HTMLElement, options?: JSONFormatterOptions, json?: string): JSONEditor;
set(json: JSON);
get(): JSON;
setText(jsonString: string);
getText(): string;
}