Learn R Programming

jsonlite (version 1.8.8)

prettify, minify: Prettify or minify a JSON string

Description

Prettify adds indentation to a JSON string; minify removes all indentation/whitespace.

Usage

prettify(txt, indent = 4)

minify(txt)

Arguments

txt

JSON string

indent

number of spaces to indent

Examples

Run this code
myjson <- toJSON(cars)
cat(myjson)
prettify(myjson)
minify(myjson)

Run the code above in your browser using DataLab