Skip to content

formatJson

Pass in a JSON or JSON string, add Spaces and newlines to return a formatted JSON string

API

Return

argumentInstructionstype
stringReturn an objectObject

Options

argumentInstructionstypeDefault value
jsonJSON objects that need to be formattedobject,stringnull
callbackError callback, optionalfunctionnull

Example

js
import { formatJson } from 'ranuts';

const json = {
  name: 'chaxus',
  age: 3,
};

const result = formatJson(json);

console.log(result);

Released under the MIT License.