From e23ae7575c0df9dbc5bf78a8a0aa6037be0df4fd Mon Sep 17 00:00:00 2001 From: IPdotSetAF Date: Fri, 3 Jan 2025 03:50:38 +0330 Subject: [PATCH] feat: beautify checkbox - json beautify - xml beautify --- .../serialized-tool.component.html | 39 +++++++------------ .../serialized-tool.component.ts | 5 ++- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Frontend/src/app/serialized-tool/serialized-tool.component.html b/Frontend/src/app/serialized-tool/serialized-tool.component.html index fbd4b97..a4b8ea4 100644 --- a/Frontend/src/app/serialized-tool/serialized-tool.component.html +++ b/Frontend/src/app/serialized-tool/serialized-tool.component.html @@ -10,27 +10,19 @@

Serialized Tool

- +
- +
- +
- +
@@ -44,27 +36,26 @@

Serialized Tool

- +
- +
- +
- + +
+ +
+
+ + +
diff --git a/Frontend/src/app/serialized-tool/serialized-tool.component.ts b/Frontend/src/app/serialized-tool/serialized-tool.component.ts index dc177a7..d46cef0 100644 --- a/Frontend/src/app/serialized-tool/serialized-tool.component.ts +++ b/Frontend/src/app/serialized-tool/serialized-tool.component.ts @@ -34,6 +34,7 @@ export class SerializedToolComponent implements AfterContentInit { protected toLang: string = "xml"; protected status: boolean = false; protected hasError: boolean = false; + protected beautify: boolean = true; protected inputDebouncer = new Subject(); @@ -77,10 +78,10 @@ export class SerializedToolComponent implements AfterContentInit { switch (this.toLang) { case "json": - this.toCode = JSON.stringify(obj); + this.toCode = this.beautify ? JSON.stringify(obj, null, 2) : JSON.stringify(obj); break; case "xml": - this.toCode = new xmlStringify().build(obj); + this.toCode = this.beautify ? new xmlStringify({ format: true }).build(obj) : new xmlStringify().build(obj); break; case "yaml": this.toCode = YAML.stringify(obj);