Skip to main content

format_json

Function format_json 

Source
pub fn format_json(input: &str) -> Result<String, Error>
Expand description

Formats JSON (.json, tsconfig.json, .vscode/*.json) matching VS Code Prettier 3.7.4 json parser (tabWidth: 2, printWidth: 80, objectWrap: "preserve", allows comments, strips trailing commas).

§Arguments

  • &str - Raw JSON source text.

§Returns

  • Result<String, io::Error> - Formatted JSON text, or an invalid-data I/O error on syntax failure.