Нашел функциию в интернете и слегка доработал её под свой стиль.

 0 && $json[$i-1] != "," && $json[$i-1] != "[" && $json[$i-1] != "{")
      {
        $result .= $newLine . $indention;
      }
    }
    // If this character is the end of an element,
    // output a new line and indent the next line
    if ($char == '}' || $char == ']') 
    {
      $indention = str_repeat($indentStr, --$ind);
      $result .= $newLine . $indention;
    }
     
    // Add the character to the result string
    if($char == ":")
    {
      $result .= " $char ";
    }
    else
    {
      $result .= $char;
    }
     
    // If the last character was the beginning of an element,
    // output a new line and indent the next line
    if ($char == ',' || $char == '{' || $char == '[') 
    {
      if ($char == '{' || $char == '[') 
      {
        $indention = str_repeat($indentStr, $ind);
      }
      $result .= $newLine . $indention;
    }

  }
   
  return $result;
}

Печатает примерно такое:

{
    "fileCount" : 2,
    "data" : 
    [
        {
            "id" : "file.1",
            "class" : "file",
            "file" : "example_file.1.html",
            "display" : "example_file.1",
            "extension" : "html",
            "size" : 12345,
            "hasVersions" : true,
            "versions" : 
            {
                "fileCount" : 1,
                "data" : 
                [
                    {
                        "id" : "file.1.1",
                        "class" : "file",
                        "file" : "example_file.1.1.html",
                        "display" : "example_file.1.1",
                        "extension" : "html",
                        "size" : 12345,
                        "hasVersions" : false,
                        "versions" : null
                    }
                ]
            }
        },
        {
            "id" : "file.2",
            "class" : "file",
            "file" : "example_file.2.html",
            "display" : "example_file.2",
            "extension" : "html",
            "size" : 12345,
            "hasVersions" : false,
            "versions" : null
        }
    ]
}