From 6f4ee8b7b6c8f4d2d8dbee353ebe9a327b110146 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 23 Nov 2018 16:05:51 +0000 Subject: [PATCH] Tidied JSON Beautify op. Changed default indent to 4 spaces instead of a tab. --- src/core/operations/JSONBeautify.mjs | 6 +++--- test/tests/operations/JSONBeautify.mjs | 2 +- test/tests/operations/JSONMinify.mjs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/operations/JSONBeautify.mjs b/src/core/operations/JSONBeautify.mjs index 83af32e0..a2b2dfdd 100644 --- a/src/core/operations/JSONBeautify.mjs +++ b/src/core/operations/JSONBeautify.mjs @@ -28,7 +28,7 @@ class JSONBeautify extends Operation { { "name": "Indent string", "type": "binaryShortString", - "value": "\\t" + "value": " " }, { "name": "Sort Object Keys", @@ -44,8 +44,8 @@ class JSONBeautify extends Operation { * @returns {string} */ run(input, args) { - const indentStr = args[0]; - const sortBool = args[1]; + const [indentStr, sortBool] = args; + if (!input) return ""; if (sortBool) { input = JSON.stringify(JSONBeautify._sort(JSON.parse(input))); diff --git a/test/tests/operations/JSONBeautify.mjs b/test/tests/operations/JSONBeautify.mjs index 30427317..5a89bd92 100644 --- a/test/tests/operations/JSONBeautify.mjs +++ b/test/tests/operations/JSONBeautify.mjs @@ -3,7 +3,7 @@ * * @author Phillip Nordwall [Phillip.Nordwall@gmail.com] * - * @copyright Crown Copyright 2017 + * @copyright Crown Copyright 2018 * @license Apache-2.0 */ import TestRegister from "../../TestRegister"; diff --git a/test/tests/operations/JSONMinify.mjs b/test/tests/operations/JSONMinify.mjs index 4bbccf8d..4feefabf 100644 --- a/test/tests/operations/JSONMinify.mjs +++ b/test/tests/operations/JSONMinify.mjs @@ -3,7 +3,7 @@ * * @author Phillip Nordwall [Phillip.Nordwall@gmail.com] * - * @copyright Crown Copyright 2017 + * @copyright Crown Copyright 2018 * @license Apache-2.0 */ import TestRegister from "../../TestRegister";