public static function indent(string $strJSON) : string
    {
        $strReturn = "";
        $indentLevel = 0;

        $insideQuotes = false;
        $insideEscape = false;

        $endLineLevel = null;

        $utf8split = preg_split('//u', $strJSON, -1, PREG_SPLIT_NO_EMPTY);
        for ($i = 0; $i < count($utf8split); $i++) {
            $c = $utf8split[$i];
            $newLineLevel = null;
            $post = "";

            if ($endLineLevel !== null) {
                $newLineLevel = $endLineLevel;
                $endLineLevel = null;
            }


            if ($insideEscape === true) {
                $insideEscape = false;
            } elseif ($c === '"') {
                $insideQuotes = !$insideQuotes;
            } elseif ($insideQuotes === false) {
                switch ($c) {
                    case "}":
                    case "]":
                        $indentLevel--;
                        $endLineLevel = null;
                        $newLineLevel = $indentLevel;
                        break;

                    case "{":
                    case "[":
                        $indentLevel++;
                    case ",":
                        $endLineLevel = $indentLevel;
                        break;

                    case ":":
                        $post = " ";
                        break;

                    case " ":
                    case "\t":
                    case "\n":
                    case "\r":
                        $c = "";
                        $endLineLevel = $newLineLevel;
                        $newLineLevel = null;
                        break;
                }
            } elseif ($c === "\\") {
                $insideEscape = true;
            }


            if ($newLineLevel !== null) {
                $strReturn .= "\n" . str_repeat("\t", $newLineLevel);
            }

            $strReturn .= $c . $post;
        }

        return $strReturn;
    }