waargonaut-0.5.2.1: JSON wrangling

Safe HaskellNone
LanguageHaskell2010

Waargonaut.Prettier

Contents

Description

Functions and types for pretty printing the Json data structures.

Synopsis

Types

data InlineOption Source #

Some choices for how the Json is indented.

Constructors

ArrayOnly

Only keep array elements on the same line, input line breaks between object values.

ObjectOnly

Only keep object elements on the same line, input line breaks between array values.

Both

Keep both object and array elements on the same line.

Neither

Input line breaks for both array and object elements.

newtype NumSpaces Source #

Newtype to indicate how many spaces we would like to use for the indentation

Constructors

NumSpaces Natural 
Instances
Eq NumSpaces Source # 
Instance details

Defined in Waargonaut.Prettier

Show NumSpaces Source # 
Instance details

Defined in Waargonaut.Prettier

newtype IndentStep Source #

Newtype for how many spaces the indentation should be increased by for each level.

A safe assumption is for this value to be the same as the number of steps for the identation. Such that an indentation of two spaces will be increased by two for each subsequent level.

Constructors

IndentStep Natural 
Instances
Eq IndentStep Source # 
Instance details

Defined in Waargonaut.Prettier

Show IndentStep Source # 
Instance details

Defined in Waargonaut.Prettier

Functions

prettyJson :: InlineOption -> IndentStep -> NumSpaces -> Json -> Json Source #

Apply some indentation and spacing rules to a given Json input.

To apply newlines to object elements only and indent by two spaces, increasing that indentation by two spaces for each nested object or array.

prettyJson ArrayOnly 2 2 j

simpleEncodePretty :: Applicative f => InlineOption -> IndentStep -> NumSpaces -> Encoder f a -> a -> f Text Source #

Encode an a directly to a ByteString using the provided Encoder, the output will have newlines and indentation added based on the InlineOption and NumSpaces.