0

Pretty Print JSON

by
Published Jun 6, 2022
Script helper Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
export async function main(value: object | string, indentation = 2) {
4
  if (typeof value === "string") {
5
    value = JSON.parse(value);
6
  }
7
  return JSON.stringify(value, null, indentation);
8
}
9

Other submissions
  • Submitted by jaller94 Deno
    Created 398 days ago
    1
    export async function main(value: object | string, indentation = 2) {
    2
      if (typeof value === "string") {
    3
        value = JSON.parse(value);
    4
      }
    5
      return JSON.stringify(value, null, indentation);
    6
    }
    7