aeson-prefix-0.1.0.2: Hiearchical prefixing for aeson

MaintainerJiri Marsicek <jiri.marsicek@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Prefix

Contents

Description

Hiearchical prefixing of JSON objects from Aeson Please see examples for understanding what does it mean.

Examples

usage of prefix

Basic

{ "a": { "b": 1 } } results in { "a": { "a.b": 2 }

{ "a": { "b": { "c": 1 } } } results in { "a": { "a.b": { "a.b.c": 1 } } }

Arrays

{ "a": [ { "b": 1 }, { "b": 2 } ] } is not changed

  • Arrays don't inherit the prefix from their parent keys by default

With optionPreservePrefix set to True

{ "a": [ { "b": 1 }, { "b": 2 } ] } results in { "a": [ { "a.b": 1 }, { "a.b": 2 } ] }

With optionPrefix set to "prefix"

{ "a": 1 } results in { "prefix.a": 1 }

  • This affects only keys in top level object.
  • If array is top level, it doesn't take effect unless you set optionPreservePrefix to True

With optionSeparator set to "~"

{ "a": { "b": 1 } } results in { "a": { "a~b": 2 } }

Synopsis

Documentation

prefix :: forall m. (Monad m, MonadReader Options m) => Value -> m Value Source #

Prefixes supplied Value using Options

Options

data Options Source #

Constructors

Options 

Fields

Instances

Utility functions and types

type Pair = (Text, Value) Source #

prefixKey :: forall m. (Monad m, MonadReader Options m) => Text -> m Text Source #

Prefixes text with prefix if defined in options, a separator from options is used to delimit prefix and text

prefixPair :: forall m. (Monad m, MonadReader Options m) => Pair -> m Pair Source #

Prefixes identifier (first in pair), this prefixed identifier is used as a prefix for value (second in pair)

withPrefix :: Prefix -> Options -> Options Source #

Change options to use supplied prefix

withoutPrefix :: Options -> Options Source #

Change options to not use any prefix