waargonaut-0.8.0.2: JSON wrangling
Safe HaskellNone
LanguageHaskell2010

Waargonaut.Prettier

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.

Instances

Instances details
Eq InlineOption Source # 
Instance details

Defined in Waargonaut.Prettier

Show InlineOption Source # 
Instance details

Defined in Waargonaut.Prettier

newtype NumSpaces Source #

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

Constructors

NumSpaces Natural 

Instances

Instances details
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

Instances details
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.

let two = successor' $ successor' zero'
prettyJson ArrayOnly (IndentStep two) (NumSpaces two) j

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

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

let two = successor' $ successor' zero'
simpleEncodePretty ArrayOnly (IndentStep two) (NumSpaces two) myEncoder myVal

Rexports

_Natural :: AsNatural a => Prism' a Natural #

data Natural #

Instances

Instances details
Eq Natural 
Instance details

Defined in Natural

Methods

(==) :: Natural -> Natural -> Bool #

(/=) :: Natural -> Natural -> Bool #

Ord Natural 
Instance details

Defined in Natural

Show Natural 
Instance details

Defined in Natural

Semigroup Natural 
Instance details

Defined in Natural

Monoid Natural 
Instance details

Defined in Natural

AsNatural Natural 
Instance details

Defined in Natural

Methods

_Natural :: Prism' Natural Natural #

AsPositive Natural 
Instance details

Defined in Natural

Methods

_Positive :: Prism' Natural Positive

HasNatural Natural 
Instance details

Defined in Natural

Methods

natural :: Lens' Natural Natural